在使用ext:Window循环打开同一页面的问题

Nov 22, 2009 at 5:27 PM

我在使用ext:Window时遇到一个问题,就是循环打开同一页面时,只能循环一次,师傅帮看一下是我使用的问题还是Window控件的限制或者是bug问题?

TestW.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="TestW.aspx.cs" Inherits="Web.TestW" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>无标题页</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <ext:PageManager ID="PageManager1" runat="server" />
        <ext:Button ID="Button1" runat="server" Text="显示窗口"></ext:Button>
        <ext:Window ID="Window1" runat="server"  EnableIFrame="true" IFrameUrl="#"
            Height="540px" IsModal="true" Popup="false"
            Title="Window" Width="780px" onclose="Window1_Close">
        </ext:Window>
    </div>
    </form>
</body>
</html>

TestW.aspx.cs

using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

namespace Web
{
    public partial class TestW : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                string WinFlag = "";
                try
                {
                    WinFlag = Request.QueryString["WinFlag"].ToString();
                }
                catch
                {
                }
                long winWidth = 780;
                long winHeight = 540;
                long winNum = 1;
                if (WinFlag == "1")
                {
                    try
                    {
                        winWidth = Convert.ToInt32(Session["WinWidth"]) - 80;
                        winHeight = Convert.ToInt32(Session["WinHeight"]) - 60;
                        winNum = Convert.ToInt32(Session["winNum"]) + 1;
                    }
                    catch
                    {
                    }
                }
                Button1.Text = "显示第" + winNum .ToString()+ "层窗口";
                Session["winNum"] = winNum.ToString();
                Session["WinWidth"] = winWidth.ToString();
                Session["WinHeight"] = winHeight.ToString();
                string winWidthStr = Session["WinWidth"].ToString() + "px";
                string winHeightStr = Session["WinHeight"].ToString() + "px";
                Unit m_UnitwinWidth = new Unit(winWidthStr);
                Unit m_UnitwinwinHeight = new Unit(winHeightStr);
                this.Window1.Width = m_UnitwinWidth;
                this.Window1.Height = m_UnitwinwinHeight;

                string str = "/TestW.aspx?WinFlag=1";
                //string str = "/TestW1.aspx?WinFlag=1";
                Button1.OnClientClick = Window1.GetShowReference(str);
            }
        }

        protected void Window1_Close(object sender, ExtAspNet.WindowCloseEventArgs e)
        {
            try
            {
                long winWidth = Convert.ToInt32(Session["WinWidth"]) + 80;
                long winHeight = Convert.ToInt32(Session["WinHeight"]) + 60;
                long winNum = Convert.ToInt32(Session["winNum"]) - 1;
                Session["WinWidth"] = winWidth.ToString();
                Session["WinHeight"] = winHeight.ToString();
                Session["winNum"] = winNum.ToString();
            }
            catch
            {
            }
        }
    }
}

 

Coordinator
Nov 23, 2009 at 11:43 AM

哈哈,你可真会玩。

先看下我实现的效果:

Coordinator
Nov 23, 2009 at 11:45 AM

主要原因应该是你每次的URL都是一样的,这样IFRAME中的页面会有缓存,你试着每次指定不同的URL就可以了:

    <ext:PageManager ID="PageManager1" runat="server" />
    <ext:Button ID="Button1" runat="server" EnablePostBack="false" Text="显示窗口">
    </ext:Button>
    <ext:Window ID="Window1" runat="server" EnableIFrame="true" IFrameUrl="#" IsModal="true"
        Popup="false" Title="Window">
    </ext:Window>


        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                int level = 0;
                string levelStr = Request.QueryString["level"];
                if (!String.IsNullOrEmpty(levelStr))
                {
                    level = Convert.ToInt32(levelStr);
                }

                int width = (1024 - level * 120);
                Window1.Width = (Unit)width;
                Window1.Height = (Unit)(768 * width / 1024);

                level++;

                Button1.Text = "显示第" + level.ToString() + "层窗口";
                string str = "~/test2.aspx?level=" + level.ToString();
                Button1.OnClientClick = Window1.GetShowReference(str);
            }
        }

Nov 23, 2009 at 10:29 PM

非常感谢,在做项目中用到这个