Robin's Blog

记录 积累 学习 成长

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::
问:

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


答:

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 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.
posted on 2009-02-11 17:00  Robin99  阅读(175)  评论(0编辑  收藏  举报