以下代码在环境:Microsoft Visual Studio 2005 (Service Pack1)下测试通过,目前也应用于项目中,感觉还行
此应用有三个窗口:
第一、Windows1.aspx
<%@PageLanguage="C#"AutoEventWireup="true"CodeBehind="Windows1.aspx.cs"Inherits="TaoNet.Client.Web.Windows1"%>
<!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<htmlxmlns="http://www.w3.org/1999/xhtml">
<headid="Head1"runat="server">
<title>WebForm1</title>
</head>
<bodyms_positioning="GridLayout">
<divalign="center">
<formid="Form1"runat="server"method="post">
<asp:LabelID="Label1"runat="server"Font-Bold="true">
从当前页面打开新窗口,并把变量传递到新窗口的例子,可以多次打开提交。
</asp:Label><br>
<br>
<asp:TextBoxID="TextBox1"runat="server"Width="600px">这是初始值,将被传递到新窗口。</asp:TextBox><br>
<br>
<asp:ButtonID="Button1"runat="server"Text="打开窗口"Width="96px"/></form>
</div>
</body>
</html>
usingSystem;
usingSystem.Data;
usingSystem.Configuration;
usingSystem.Collections;
usingSystem.Web;
usingSystem.Web.Security;
usingSystem.Web.UI;
usingSystem.Web.UI.WebControls;
usingSystem.Web.UI.WebControls.WebParts;
usingSystem.Web.UI.HtmlControls;
namespaceTaoNet.Client.Web
...{
publicpartialclassWindows1:System.Web.UI.Page
...{
protectedvoidPage_Load(objectsender,EventArgse)
...{
intintWidth=500;
intintHeight=400;
stringvbCrLf=" ";
//在此处放置用户代码以初始化页面
if(!IsClientScriptBlockRegistered("clientScript"))
...{
stringstrScript="<script>"+vbCrLf;
strScript+="functionOpenWin(){"+vbCrLf;
strScript+="varstr=window.showModalDialog('Windows2.aspx',document.Form1.TextBox1.value,'dialogWidth="+intWidth+"px;dialogHeight="+intHeight+"px','scroll:yes')"+vbCrLf;
strScript+="if(str!=null)document.Form1.TextBox1.value=str"+vbCrLf;
strScript+="}"+vbCrLf;
strScript+="</script>"+vbCrLf;
RegisterClientScriptBlock("clientScript",strScript);
}
Button1.Attributes.Add("onclick","OpenWin()");
//window.showModalDialog("modal.htm",obj,"dialogWidth=200px;dialogHeight=100px");
}
}
}
//------------------------------------------------------------------------------
//<auto-generated>
//此代码由工具生成。
//运行库版本:2.0.50727.42
//
//对此文件的更改可能会导致不正确的行为,并且如果
//重新生成代码,这些更改将会丢失。
//</auto-generated>
//------------------------------------------------------------------------------

namespaceTaoNet.Client.Web...{


/**////<summary>
///Windows1类。
///</summary>
///<remarks>
///自动生成的类。
///</remarks>
publicpartialclassWindows1...{

/**////<summary>
///Head1控件。
///</summary>
///<remarks>
///自动生成的字段。
///要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
///</remarks>
protectedglobal::System.Web.UI.HtmlControls.HtmlHeadHead1;

/**////<summary>
///Form1控件。
///</summary>
///<remarks>
///自动生成的字段。
///要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
///</remarks>
protectedglobal::System.Web.UI.HtmlControls.HtmlFormForm1;

/**////<summary>
///Label1控件。
///</summary>
///<remarks>
///自动生成的字段。
///要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
///</remarks>
protectedglobal::System.Web.UI.WebControls.LabelLabel1;

/**////<summary>
///TextBox1控件。
///</summary>
///<remarks>
///自动生成的字段。
///要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
///</remarks>
protectedglobal::System.Web.UI.WebControls.TextBoxTextBox1;

/**////<summary>
///Button1控件。
///</summary>
///<remarks>
///自动生成的字段。
///要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
///</remarks>
protectedglobal::System.Web.UI.WebControls.ButtonButton1;
}
}
第二、Windows2.aspx
<%@PageLanguage="C#"AutoEventWireup="true"CodeBehind="Windows2.aspx.cs"Inherits="TaoNet.Client.Web.Windows2"%>
<!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<htmlxmlns="http://www.w3.org/1999/xhtml">
<headid="Head1"runat="server">
<title>WebForm2</title>
</head>
<framesetrows="0,*">
<framesrc="about:blank">
<framesrc="Windows3.aspx">
</frameset>
</html>
usingSystem;
usingSystem.Data;
usingSystem.Configuration;
usingSystem.Collections;
usingSystem.Web;
usingSystem.Web.Security;
usingSystem.Web.UI;
usingSystem.Web.UI.WebControls;
usingSystem.Web.UI.WebControls.WebParts;
usingSystem.Web.UI.HtmlControls;
namespaceTaoNet.Client.Web
...{
publicpartialclassWindows2:System.Web.UI.Page
...{
protectedvoidPage_Load(objectsender,EventArgse)
...{
}
}
}
//------------------------------------------------------------------------------
//<auto-generated>
//此代码由工具生成。
//运行库版本:2.0.50727.42
//
//对此文件的更改可能会导致不正确的行为,并且如果
//重新生成代码,这些更改将会丢失。
//</auto-generated>
//------------------------------------------------------------------------------

namespaceTaoNet.Client.Web...{


/**////<summary>
///Windows2类。
///</summary>
///<remarks>
///自动生成的类。
///</remarks>
publicpartialclassWindows2...{

/**////<summary>
///Head1控件。
///</summary>
///<remarks>
///自动生成的字段。
///要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
///</remarks>
protectedglobal::System.Web.UI.HtmlControls.HtmlHeadHead1;
}
}
第二、Windows3.aspx
<%@PageLanguage="C#"AutoEventWireup="true
本文介绍了一个使用ASP.NET Web窗体的应用示例,包括三个窗口:Windows1用于显示初始值并打开新窗口;Windows2展示如何使用iframe加载另一个页面;Windows3则作为iframe加载的内容。
288

被折叠的 条评论
为什么被折叠?



