How do I click the button to pop up a new window, enter data and then return and refresh the page?

Source: Internet
Author: User
Tags generator visual studio
button | data | refresh | page in some. NET Forum Some people often ask: How to click the button in the page to open a new page, enter data, and then return to the original page and update? To solve this problem, we should make clear the use of window.showModalDialog (), I have been introduced in http://www.csdn.net/Develop/read_article.asp?id=15113. Here is an example of how to implement this functionality in ASP.net.

This example is a total of 3 pages, where webform2.aspx is a transition page to prevent the new page from being opened when it is submitted.

WebForm1.aspx

<%@ Page language= "vb" 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= "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" >
The example of opening a new window from the current page and passing the variable to the new window allows you to open the submission multiple times.
</asp:label><br>
<br>
<asp:textbox id= "TextBox1" runat= "Server" width= "600px" > This is the initial value and will be passed to the new window. </asp:textbox><br>
<br>
<asp:button id= "Button1" runat= "Server" text= "open Window" 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 the code generated by the Web Forms Designer

' This call is required by the Web Forms Designer.
<system.diagnostics.debuggerstepthrough () > Private Sub InitializeComponent ()

End Sub

Private Sub Page_Init (ByVal sender as System.Object, ByVal e as System.EventArgs) Handles Mybase.init
' CodeGen: This method call is required by the Web Forms Designer
' Do not modify it using the Code Editor.
InitializeComponent ()
End Sub

#End Region

Private Sub Page_Load (ByVal sender as System.Object, ByVal e as System.EventArgs) Handles MyBase.Load
' The user code to place the initialization page here
If (Not isclientscriptblockregistered ("ClientScript")) Then
Dim strscript as String = "<script>" + vbCrLf
Strscript + = "function Openwin () {" + VbCrLf
Strscript + = "var Str=window.showmodaldialog" (' webform2.aspx ', document. Form1.TextBox1.value) "+ vbCrLf
Strscript + = "if (str!=null) document." Form1.textbox1.value=str "+ vbCrLf
Strscript + = "}" + VbCrLf
Strscript = "</script>" + vbCrLf
RegisterClientScriptBlock ("ClientScript", Strscript)
End If
BUTTON1.ATTRIBUTES.ADD ("onclick", "Openwin ()")
End Sub

End Class

Webform2.aspx

<%@ Page language= "vb" autoeventwireup= "false" codebehind= "WebForm2.aspx.vb" inherits= " AspxWeb.mengxianhui.com.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.0" >
<meta name= "Code_language" content= "Visual Basic 7.0" >
<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>

WebForm2.aspx.vb

Public Class WebForm2
Inherits System.Web.UI.Page

#Region the code generated by the Web Forms Designer

' This call is required by the Web Forms Designer.
<system.diagnostics.debuggerstepthrough () > Private Sub InitializeComponent ()



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.