JavaScript 调用后台 c# 方法

问:

i want to call c# function from javascript and also want to pass argument to that function.


答:

Hi [email protected]
 
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 mechanism

3.       put a button in your page, and set its style="display:none", write your C# function in the button’s onclick event, then you can call it on client-side by:
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.

你可能感兴趣的:(JavaScript)