Passing parameters between ASP. NET web form child parent forms

Source: Internet
Author: User
Two pages Code As follows:
Page. aspx (parent form) < Html >
< Body >
< Script Language = " C # " Runat = " Server " >
</ Script >
< Form ID = " Form1 " Method = Post runat = " Server " >
< ASP: textbox ID = Txtname runat = Server > </ ASP: textbox >
< Input type = Button Value = " Dialog Box " Onclick = " Mywin = Window. Open ('subpage. aspx '); " >
</ Form >
</ Body >
</ Html >

Subpage. aspx (subform) < Html >
< Body >
< Script Language = " Javascript " >
Function Popup ()
{
Zookeeper opener.doc ument. All [ " Txtname " ]. Value = Document. All [ " Txtsubname " ]. Value;
Window. Close ()
}
</ Script >
< Script Language = " C # " Runat = " Server " >
</ Script >
< Form ID = " Form1 " Method = Post runat = " Server " >
< ASP: textbox ID = Txtsubname runat = Server > </ ASP: textbox >
< P > < Input type = " Button " Value = " Pass the value and return to the parent window " Name = " Button1 " Onclick = " Popup () " > </ P >
</ Form >
</ Body >
</ Html >

Notes:
1. The child form is displayed. the textbox value of the child form is passed to the parent form.
2. Both buttons use HTML controls or can be replaced with server controls of Asp.net. As for how to call JScript by server controls, here is a tip: execute such code in the button_click event.StringScript="<Script language = "JavaScript"> window. Open ('subpage. aspx '); </SCRIPT>"
Response. Write (SCRIPT );

In this way, the JavaScript code is executed.

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.