All articles| All Pictures| All Softwares| All Video| Go home page| Write articles| Upload pictures

Reading number is top 10 articles
通过反射填充泛型集合List的静态方法_.net资料_编程技术
SQL Server中存储过程的安全问题_[SQL Server教程]
PHPer为什么被认为是草根?_php资料_编程技术
SQL2000系统表的应用_[SQL,Server教程]
ASP.NET Remoting体系结构(九)
visual c++中的画笔类CPen使用实例
构建安全的Xml,Web,Service系列
PHP加密文本文件并限制特定页面的存取_php资料_编程技术
了解c#2.0中的Anonymous,Methods(匿名方法)_[Asp.Net教程]
关于ASP.NET页面打印技术的总结_[Asp.Net教程]
Reading number is top 10 pictures
The money of more than 100 countries and regions8
这才叫绝色美女1
Send some Valentine's day cartoon
世界各国15岁的MM有什么不同
这才是真正的人体艺术5
Discharge accidentally Actresses by the breast1
Sora aoi in China1
Absolutely shocked. National geographic 50 animal photographys5
Small QiShu -- ShuangShuangPan1
Magnificent cloud2
Download software ranking
Unix video tutorial20
Boxer's Top ten classic battle10
传奇私服架设教程
Tram sex maniac 2 (H) rar bag4
网络管理员第三版
SP4 for SQL2000
VeryCD电驴(EasyMule) V1.1.9 Build09081
美女写真1
金山office2007
Boxer's Top ten classic battle6
delv published in(发表于) 2014/1/16 9:32:39 Edit(编辑)
如何点击按钮弹出新窗口,输入数据后返回并刷新页面?_[Asp.Net教程]

如何点击按钮弹出新窗口,输入数据后返回并刷新页面?_[Asp.Net教程]

如何点击按钮弹出新窗口,输入数据后返回并刷新页面?_[Asp.Net教程]

在一些.NET论坛中有人经常会问:如何在页面中点击按钮打开新页面,输入数据,然后返回到初始页面并进行更新?要解决这个问题,应该弄清楚window.showModalDialog()的用法,本人在http://www.csdn.net/Develop/read_article.asp?id=15113已经做过介绍。下面就用例子介绍如何在ASP.NET中实现这个功能。


本例子共3个页面,其中WebForm2.aspx是过渡页面,是为了防止提交时打开新页面。


WebForm1.aspx

<%@ Page Language="vb" AutoEventWireup="false" Codebehind="WebForm1.aspx.vb"<br/>Inherits="ShowModalDialog.WebForm1" %><br/><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><br/><HTML><br/><HEAD><br/><title>WebForm1</title><br/></HEAD><br/><body MS_POSITIONING="GridLayout"><br/><form id="Form1" method="post" runat="server"><br/><asp:label id="Label1" runat="server" Font-Bold="true"><br/>从当前页面打开新窗口,并把变量传递到新窗口的例子,可以多次打开提交。<br/></asp:label><br/><asp:textbox id="TextBox1" runat="server" Width="600px">这是初始值,将被传递到新窗口。</asp:textbox><br/><asp:button id="Button1" runat="server" Text="打开窗口" Width="96px"></asp:button></form><br/></body><br/></HTML><br/>

WebForm1.aspx.vb

Public Class WebForm1<br/>Inherits System.Web.UI.Page<br/>Protected WithEvents TextBox1 As System.Web.UI.WebControls.TextBox<br/>Protected WithEvents Form1 As System.Web.UI.HtmlControls.HtmlForm<br/>Protected WithEvents Label1 As System.Web.UI.WebControls.Label<br/>Protected WithEvents Button1 As System.Web.UI.WebControls.Button<br/>#Region " Web 窗体设计器生成的代码 "<br/>'该调用是 Web 窗体设计器所必需的。<br/><System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()<br/>End Sub<br/>Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init<br/>'CODEGEN: 此方法调用是 Web 窗体设计器所必需的<br/>'不要使用代码编辑器修改它。<br/>InitializeComponent()<br/>End Sub<br/>#End Region<br/>Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load<br/>'在此处放置初始化页的用户代码<br/>If (Not IsClientScriptBlockRegistered("clientScript")) Then<br/>Dim strScript As String = "" + vbCrLf<br/>strScript += "function OpenWin(){" + vbCrLf<br/>strScript += "var str=window.showModalDialog('WebForm2.aspx',document.Form1.TextBox1.value)" + vbCrLf<br/>strScript += "if(str!=null) document.Form1.TextBox1.value=str" + vbCrLf<br/>strScript += "}" + vbCrLf<br/>strScript += "" + vbCrLf<br/>RegisterClientScriptBlock("clientScript", strScript)<br/>End If<br/>Button1.Attributes.Add("<I>onclick</I>", "OpenWin()")<br/>End Sub<br/>End Class<br/>

WebForm2.aspx

<%@ Page Language="vb" AutoEventWireup="false" Codebehind="WebForm2.aspx.vb" Inherits="aspxWeb.mengxianhui.com.WebForm2"%><br/><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><br/><HTML><br/><HEAD><br/><title>WebForm2</title><br/></HEAD><br/></frameset><br/></HTML><br/>

WebForm2.aspx.vb

Public Class WebForm2<br/>Inherits System.Web.UI.Page<br/>#Region " Web 窗体设计器生成的代码 "<br/>'该调用是 Web 窗体设计器所必需的。<br/><System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()<br/>End Sub<br/>Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init<br/>'CODEGEN: 此方法调用是 Web 窗体设计器所必需的<br/>'不要使用代码编辑器修改它。<br/>InitializeComponent()<br/>End Sub<br/>#End Region<br/>Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load<br/>'在此处放置初始化页的用户代码<br/>End Sub<br/>End Class<br/>

WebForm3.aspx

<%@ Page Language="vb" AutoEventWireup="false" Codebehind="WebForm3.aspx.vb"<br/>Inherits="ShowModalDialog.WebForm3" %><br/><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><br/><HTML><br/><HEAD><br/><title>WebForm3</title><br/> <br/></HEAD><br/><body MS_POSITIONING="GridLayout" id="MyBody" runat="server"><br/><form id="Form1" method="post" runat="server"><br/><asp:Label id="Label1" runat="server">请输入您的大名:</asp:Label><br/><asp:TextBox id="TextBox1" runat="server" Width="558"></asp:TextBox><br/><asp:Button id="Button1" runat="server" Text=" 提 交 "></asp:Button><br/></form><br/></body><br/></HTML><br/>

WebForm3.aspx.vb

Public Class WebForm3<br/>Inherits System.Web.UI.Page<br/>Protected WithEvents TextBox1 As System.Web.UI.WebControls.TextBox<br/>Protected WithEvents Label1 As System.Web.UI.WebControls.Label<br/>Protected WithEvents Button1 As System.Web.UI.WebControls.Button<br/>Protected MyBody As System.Web.UI.HtmlControls.HtmlControl<br/>#Region " Web 窗体设计器生成的代码 "<br/>'该调用是 Web 窗体设计器所必需的。<br/><System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()<br/>End Sub<br/>Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init<br/>'CODEGEN: 此方法调用是 Web 窗体设计器所必需的<br/>'不要使用代码编辑器修改它。<br/>InitializeComponent()<br/>End Sub<br/>#End Region<br/>Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load<br/>'在此处放置初始化页的用户代码<br/>If IsPostBack Then<br/>Dim strScript As String = "" + vbCrLf<br/>strScript += "window.parent.returnValue='" + TextBox1.Text.Replace("'", "\'") + "'" + vbCrLf<br/>strScript += "window.parent.close()" + vbCrLf<br/>strScript += "" + vbCrLf<br/>If (Not IsClientScriptBlockRegistered("clientScript")) Then<br/>RegisterClientScriptBlock("clientScript", strScript)<br/>End If<br/>End If<br/>If Not IsPostBack Then<br/>MyBody.Attributes.Add("onload", "document.Form1.TextBox1.value=window.parent.dialogArguments")<br/>End If<br/>End Sub<br/>End Class<br/> 作者:孟宪会 出自:【孟宪会之精彩世界】





添加到del.icio.us 添加到新浪ViVi 添加到百度搜藏 添加到POCO网摘 添加到天天网摘365Key 添加到和讯网摘 添加到天极网摘 添加到黑米书签 添加到QQ书签 添加到雅虎收藏 添加到奇客发现 diigo it 添加到饭否 添加到飞豆订阅 添加到抓虾收藏 添加到鲜果订阅 digg it 貼到funP 添加到有道阅读 Live Favorites 添加到Newsvine 打印本页 用Email发送本页 在Facebook上分享


Disclaimer Privacy Policy About us Site Map

If you have any requirements, please contact webmaster。(如果有什么要求,请联系站长)
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.