Javascript calls the C # method in the background

Source: Internet
Author: User
Q:

I want to call C # function from JavaScript and also want to pass argument to that function.

A:

Hi Vrparekh@gmail.com
 
Please check the following thread, his question is same to yours:
 
Want to call a function of C #. Net from Javascript
Http://forums.asp.net/t/1281156.aspx
 
Generally speaking, THe ways to achieve:

1. Using ajax with Web Services
2. implement callback mechanic

3.Put a button in your page, and set itsStyle = "display: none", write your C # function in the button's onclick event, then you can call it on client-side:
Document. getelementbyid ("btnname"). Click ();


4. Using a httphandler and attributes to call C # methods in Javascript, you can find the way in Michael Schwarz's blog:
Http://weblogs.asp.net/mschwarz/archive/2005/02/15/373072.aspx
 
If I 've misunderstood your problem, please feel free to let me know.
 
Thanks.

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.