How. NET passes the value of a variable to the foreground JS in the background

Source: Internet
Author: User

How does the C # background computed value be assigned to the foreground

First defined in the background, example: public int ID, (to protected void Page_Load (object sender, EventArgs e),
You can then start the value in protected void Page_Load (object sender, EventArgs e) or get the value of the foreground input
Finally in the foreground JS var id= "<%=id%>";

  1. This is the value of the pass variable name.
  2. In HTML JS
  3. var srcurl = <%=getUrl%>;
  4. var srcurl = <%=getUrl%>;
  5. In the CS class file
  6. Public static string getUrl = "url";
  7. Public static string getUrl = URL;
  8. If you want to pass the value of a method
  9. In HTML JS
  10. var srcurl = <%=geturl ()%>;
  11. var srcurl = <%=geturl ()%>;
  12. C # code public static string GetUrl ()
  13. { return "returned value"; }    
  14. Public static string GetUrl () {return value;}

How. NET passes the value of a variable to the foreground JS in the background

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.