如何在Asp.Net中使用Jquery按钮单击事件来调用Codebehind函数 [英] How Can I Call A Codebehind Function Using Jquery On Button Click Event In Asp.Net

查看:68
本文介绍了如何在Asp.Net中使用Jquery按钮单击事件来调用Codebehind函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在点击事件的按钮上使用jquery调用一个代码隐藏方法。

例如,如果我点击一个按钮然后它调用一个jquery函数然后Jquery方法调用服务器端方法。



请指教。

i want to call a code behind method using jquery on the button on click event.
for example if i click on a button then it calls a jquery function then Jquery method call the server side method.

please advise.

推荐答案

你不能调用它,因为Javascript适用于客户端侧;代码隐藏在服务器端。在发送一些HTTP请求之前,服务器端没有任何事情发生。因此,只有在发送HTTP请求并接收一些HTTP响应时,才能从服务器端获取一些数据。从您的Javascript函数,您不能使用Web表单(您可能没有),因此如果Ajax发送此类请求的唯一方法:

http://en.wikipedia.org/wiki/Ajax_(编程) [ ^ ]。



使用Ajax的一种便捷方法是使用jQuery Ajax: http://api.jquery.com/jquery.ajax [ ^ ]。



-SA
You cannot "call" it, because Javascript works on the client side; and the code-behind is on the server side. Nothing happens on the server side until you send some HTTP request. So, you can get some data from the server side only if you send HTTP request and receive some HTTP response. From your Javascript function, you cannot use the Web form (which you may not have), so the only way to send such request if Ajax:
http://en.wikipedia.org/wiki/Ajax_(programming)[^].

One convenient way to use Ajax is using jQuery Ajax: http://api.jquery.com/jquery.ajax[^].

—SA


参考: http: //csharpjournal.blogspot.in/2013/11/calling-code-behind-function-from-jquery.html [ ^ ]

这可能会有所帮助。
Refer:http://csharpjournal.blogspot.in/2013/11/calling-code-behind-function-from-jquery.html[^]
This may help.


这篇关于如何在Asp.Net中使用Jquery按钮单击事件来调用Codebehind函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆