jQuery的Ajax调用code后面的用户控制方法后面、方法、用户、jQuery

2023-09-10 17:58:17 作者:快乐嘴角渴望的知觉

,我们可以调用用户控制code后面的方法使用jQuery AJAX?

Can we call User control code behind method using Jquery ajax ?

谢谢

推荐答案

您不能直接使用jQuery的Ajax用户控件调用的方法。

You can't call a method directly in a user control using Jquery Ajax.

您可以尝试以下方法之一寿:

You can try one of the following approaches tho:

设置网址 PageName.aspx?方法= YourMethod 或者添加一些 其他限制,所以你知道哪些用户控件应该执行 方法。然后在你的用户控件,你可以检查是否存在等 在查询字符串的限制,并执行给定的方法。

Set the URL to PageName.aspx?Method=YourMethod or maybe add some other restrictions so you know which user control should execute the method. Then in your user control you can check for the existance of your restrictions in the querystring, and execute the given method.

您可以只使用客户端回调来执行一些方法,如果你 需要做的事情异步。在页面的GetCallbackResult,则 可以发现,导致回调的控制,并通过该请求 它的参数来控制。

You can just use client callback to execute some method, if you need to do something async. in the GetCallbackResult in the page, you can find the control that caused the callback, and pass the request with its arguments to the control.