The interaction between aspx and cs functions in ASP.net is necessary.

Source: Internet
Author: User

Because I don't know how to call aspx in the script of aspx. function in cs, unable to operate the GridView control, unable to read control dataset information; Because aspx is unknown. how does the cs function call the function in the script in aspx? <div> and other attributes cannot be set. Through intercommunication, you can easily solve these two problems.

The script function at the front end of aspx calls the background function in aspx. cs:

Aspx:

<Script type = "text/javascript">
Function FrontFunction ()
{
Var RetStr = <% = BehindtFunction () %>;
Alert (RetStr );
// Window. returnValue = RetStr;
// Window. close ();
// Alert ("000 ");
}
</Script>

Aspx. cs:

Protected string BehindtFunction (object sender, EventArgs e)

{

// Code

Return "null"; // a return value is required.

}

 

In aspx. cs, the background function calls the script Function of the aspx Foreground:

Aspx. cs:

Protected string BehindtFunction (object sender, EventArgs e)

{

// Code

ClientScript. RegisterStartupScript (this. GetType (), "clear", "<script> FrontFunction () </script> ");

}

Aspx:

<Script type = "text/javascript">
Function FrontFunction ()
{

Mask. style. visibility = 'visable ';
Div2.style. visibility = 'visable ';
Return false;
}
</Script>

<Div id = "mask"> </div>

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.