Learning: Interaction Between JavaScript and the background

Source: Internet
Author: User
1. Javascript Function execution C # CodeFunctions in:

 

Method 1:

1Create a button to write the called or processed content in the backgroundButton_clickMedium;

 

2WriteJSFunction. The content isDocument. getelementbyid ("btn1"). Click ();

 

3, Called at the front end or back endJSFunction, ExcitationClickEvent, equivalent to accessing the backgroundC #Function;

 

 

2. How Javascript Access C # Variable ?

 

The answer is as follows:

 

Method 1:

1Hide domain access on the page

 

Method 2:

1,As defined in the backgroundPublic String N;

2,Front-endJSTo reference the variable in the format''<%=N%>''Or"+<%=N%>+"

 

 

3. How C # Medium Access Javascript Existing variable ?

 

The answer is as follows:

 

Method 1:

1, The foreground uses static text control to hide the domainJSWrite the variable value into it;

 

2For background useRequest ["ID"]To obtain the value;

 

Method 2:

AvailableCookieOrSession

 

4. How C # Medium Access Javascript Function ?

 

The answer is as follows:

 

C #Code ExecutionJavascriptFunction:

 

Method 1:

1,Page. registerstartupscript ("ggg ","");

 

 

ArticleFrom:Http://aspnetbus.blogbus.com/logs/65718157.html

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.