[Conclusion] special discussion on the showModalDialog window!

Source: Internet
Author: User

1. Opening the modal window
2. Close the modal window
3. Transmission Parameters of the modal window.
4. Others ....

1. window. showModalDialog ("DialogPage. aspx "," newwin "," dialogHeight: 200px; dialogWidth: 150px; dialogTop: 458px; dialogLeft: 166px; edge: Raised; center: Yes; help: Yes; resizable: Yes; status: Yes ;");

2. window. close ();

3. Pass the value
ParentPage. aspx:
Window. showModalDialog ("DialogPage. aspx? Para1 = aaa & para2 = bbb ");

DialogPage. aspx:
String str1 = Request. QueryString ["para1"]. toString ();
String str2 = Request. QueryString ["para2"]. toString ();

Return Value
DialogPage. aspx:
Window. returnValue = "aaa ";

ParentPage. aspx:
Var str = window. showModalDialog ("DialogPage. aspx ");

4.
Why does the aspx page reopen a page when showmodeldialog is submitted?
On the showmodaldialog page, add a line between

 

 

5. In the data binding mode form, you can also create a template column in The DataGrid, add the Html button, and add the following to the button:
OnClick = "returnValue = '<% # DataBind. Eval (Container. DataItem," Name ") %>'; window. close ()"
You can pass the related values of the selected row of the DataGrid in the mode dialog box.

6. Example
WebForm2.aspx. vb
Inherits System. Web. UI. Page
Protected WithEvents Button1 As System. Web. UI. WebControls. Button
Protected WithEvents TextBox1 As System. Web. UI. WebControls. TextBox
Protected WithEvents Button2 As System. Web. UI. WebControls. Button
Protected WithEvents TextBox2 As System. Web. UI. WebControls. TextBox
Private Sub Page_Load (ByVal sender As System. Object, ByVal e As System. EventArgs) Handles MyBase. Load
Button1.Attributes. Add ("onclick", "var st = window. showModalDialog ('user. aspx? Val = '+ document. all ('textbox1'). value); document. all ('textbox1'). value = st; return st ;")
End Sub
Private Sub Button2_Click (ByVal sender As System. Object, ByVal e As System. EventArgs) Handles Button2.Click
RegisterStartupScript ("key", "<script> window. opener = null; window. close (this); </script> ")
End Sub
User. aspx. vb
Protected WithEvents TextBox1 As System. Web. UI. WebControls. TextBox
Protected WithEvents cancel As System. Web. UI. WebControls. Button
Protected WithEvents OK As System. Web. UI. WebControls. Button
Protected WithEvents TextBox2 As System. Web. UI. WebControls. TextBox
Private Sub Page_Load (ByVal sender As System. Object, ByVal e As System. EventArgs) Handles MyBase. Load
Dim str As String
If Not IsPostBack Then
Str = Request. QueryString ("val ")
TextBox1.Text = str
End If
End Sub
Private Sub cancel_Click (ByVal sender As System. Object, ByVal e As System. EventArgs) Handles cancel. Click
RegisterStartupScript ("key", "<script> window. returnValue = 'null'; window. opener = null; window. close (this); </script> ")
End Sub
Private Sub OK _Click (ByVal sender As Object, ByVal e As System. EventArgs) Handles OK. Click
RegisterStartupScript ("key", "<script> window. returnValue = document. all ('textbox2 '). value; window. opener = null; window. close (this); </script> ")
End Sub

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.