如何点击按钮弹出新窗口,输入数据后返回并刷新页面?(C#代码)
翻译自孟宪会之精彩世界的VB.NET代码
http://dotnet.aspx.cc/ShowDetail.aspx?id=49ML4AO8-5PB3-4KNY-NJZD-LJOIOXV4M1X4
Webform1.aspx
<%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false" Inherits="ShowModalTest.WebForm1" %>
<%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false" Inherits="ShowModalTest.WebForm1" %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" > <HTML> <HEAD> <title>WebForm1</title> <meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR"> <meta content="C#" name="CODE_LANGUAGE"> <meta content="JavaScript" name="vs_defaultClientScript"> <meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema"> </HEAD> <body MS_POSITIONING="GridLayout"> <div align="center"> <form id="Form1" method="post" runat="server"> <asp:label id="Label1" runat="server" Font-Bold="true"> 从当前页面打开新窗口,并把变量传递到新窗口的例子,可以多次打开提交。 </asp:label><br> <br> <asp:textbox id="TextBox1" runat="server" Width="600px">这是初始值,将被传递到新窗口。</asp:textbox><br> <br> <asp:button id="Button1" runat="server" Width="96px" Text="打开窗口2"></asp:button> <asp:button id="Button2" runat="server" Width="96px" Text="打开窗口4"></asp:button></form> </div> </body> </HTML> |
Webform1.aspx.cs
using System; using System.Collections; using System.ComponentModel; using System.Data; using System.Drawing; using System.Web; using System.Web.SessionState; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.HtmlControls; namespace ShowModalTest } #region Web 窗体设计器生成的代码 } |
Webform2.aspx
<%@ Page language="c#" Codebehind="WebForm2.aspx.cs" AutoEventWireup="false" Inherits="ShowModalTest.WebForm2" %> <%@ Page language="c#" Codebehind="WebForm2.aspx.cs" AutoEventWireup="false" Inherits="ShowModalTest.WebForm2" %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" > <HTML> <HEAD> <TITLE>WebForm2</TITLE> <meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1"> <meta name="CODE_LANGUAGE" Content="C#"> <meta name="vs_defaultClientScript" content="JavaScript"> <meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5"> </HEAD> <frameset rows="0,*"> <frame src="about:blank"> <frame src="WebForm3.aspx"> </frameset> </HTML> |
WebForm3.aspx
<%@ Page language="c#" Codebehind="WebForm3.aspx.cs" AutoEventWireup="false" Inherits="ShowModalTest.WebForm3" %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" > <HTML> <HEAD> <title>WebForm3</title> <meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1"> <meta name="CODE_LANGUAGE" Content="C#"> <meta name="vs_defaultClientScript" content="JavaScript"> <meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5"> </HEAD> <body MS_POSITIONING="GridLayout" id="MyBody" runat="server"> <form id="Form1" method="post" runat="server"> <asp:Label id="Label1" runat="server">请输入您的大名:</asp:Label><br> <br> <asp:TextBox id="TextBox1" runat="server" Width="320px"></asp:TextBox><br> <br> <asp:Button id="Button1" runat="server" Text=" 提 交 "></asp:Button> </form> </body> </HTML> |
WebForm3.aspx.cs
using System; namespace ShowModalTest #region Web 窗体设计器生成的代码 } |