开发者

How to call server-side function using html button?

I know this is a weird question but I was pushed to such a situation. I have to refresh a ESRI client side map and call server-function at the same time. I am using c#/asp.net/javascript.

I think we can call web service methods, but it is possible to call the server-side function of the same page.

EDITED Thanks for the reply. But I am dealing with a different situation. In my server -side function I have to access the "div" and have to add images whose URL are coming from database.Since the webmethods are static, I can't access the "div" element. Does it make any sense or am I doing开发者_Python百科 something wrong

ANSWER

txt.Attributes.Add("onclick", "refreshMap(); return false;");

I missed return false before and that's causing postback every time.

Thanks,


You could do this by having the onclick event call a function which makes an AJAX post to a method in your code-behind. This will work with WebMethods.


I am new to this but I think Mike's approach is ideal. If you find this slowing down your site, try implementing it using Web Workers.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜