在一些.net论坛中有人经常会问:如何在页面中点击按钮打开新页面,输入数据,然后返回到初始页面并进行更新?要解决这个问题,应该弄清楚window.showModalDialog()的用法,本人在http://www.csdn.net/Develop/read_article.asp?id=15113已经做过介绍。下面就用例子介绍如何在ASP.NET中实现这个功能。 本例子共3个页面,其中WebForm2.aspx是过渡页面,是为了防止提交时打开新页面。 WebForm1.aspx <%@ Page Language="<a href="http://dev.21tx.com/language/vb/" target="_blank">VB</a>" AutoEventWireup="false" Codebehind="WebForm1.aspx.vb" Inherits="ShowModalDialog.WebForm1" %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML> <HEAD> <title>WebForm1</title> <meta content="Microsoft Visual Studio .NET 7.0" name="GENERATOR"> <meta content="Visual Basic 7.0" name="CODE_LANGUAGE"> <meta content="<a href="http://dev.21tx.com/web/javascript/" target="_blank">JavaScript</a>" 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" Text="打开窗口" Width="96px"></asp:button></form> </div> </body> </HTML> WebForm1.aspx.vb Public Class WebForm1 Inherits System.Web.UI.Page Protected WithEvents TextBox1 As System.Web.UI.WebControls.TextBox Protected WithEvents Form1 As System.Web.UI.HtmlControls.HtmlForm Protected WithEvents Label1 As System.Web.UI.WebControls.Label Protected WithEvents Button1 As System.Web.UI.WebControls.Button #Region " Web 窗体设计器生成的代码 "
复制本页网址和标题,发送给你QQ/Msn的好友一起分享
上一篇:在ASP.NET中将数据直接输出成Excel格式
下一篇:利用OleDb的GetOLEDBSchemaTable方法得到数据库架构信息