Ways to pass values between ASP.net forms

Source: Internet
Author: User
This article introduced the ASP.net form to pass the value the method, has the need friend to be possible to consult, hoped has the help to you

Suppose the parentform.aspx page has a TextBox1 text box and an open button
Click the Open button to eject the Subform.aspx,subform.aspx page with the TextBox1 text box and the Close button
Clicking the Close button closes the Subform.aspx page and displays the value of the page subform.aspx text box to the Parentform.aspx text box on the parent page.
Parent form Foreground Code:

Copy Code code as follows:


<script type= "Text/javascript" >


function Opensubform (ret) {


var strpath = "Subform.aspx"


var nheight = 500


var nwidth = 500


var feature


Feature = "height=" + nheight + ", width=" + nwidth + ", top=30,left=30";


feature = ", Dependent=yes,location=no,resizable=yes,scrollbars=yes,status=yes,toolbar=no;";


window.open (strpath+)? Ret_form=form1&ret_value= "+ret, ' subform ', feature). focus ();


return false;


        }


</script>


Parent Form Background Code:

Copy Code code as follows:


private void Page_Load (object sender, System.EventArgs e)


        {


ページを initial するユーザーコードをここに 挿 into します


this. BUTTON1.ATTRIBUTES.ADD ("OnClick", "Return Opensubform (' TextBox1 ');");


        }


Sub-form Background code:

Copy Code code as follows:


        private void Button1_Click (object sender, System.EventArgs e)
& nbsp;       {
             String Strscript =string. Empty;
            string strretform = String.Empty;
            string Strretvalue=string.empty;
            strretform=request.params["Ret_form"];
            strretvalue=request.params["Ret_value"];
            if (strretform = string. Empty)
            {
                 strretform= "document.forms[0]";br>            }
             strscript = "<script language=javascript>";
            Strscript + = "Window.opener." + strretform;
            Strscript + + + Strretvalue + ". Value= '" + This. TextBox1.Text.Trim () + "';";
            Strscript + = "window.close ();";
            Strscript + = "</script>";
            Response.Write (strscript);
       }

Related Article

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.