将 UpdatePanel 替换为 JQuery

发布于 2024-07-11 01:13:19 字数 108 浏览 6 评论 0原文

我使用 UpdatePanel 异步调用页面中的按钮单击事件,该事件调用另一个类中的方法,该方法在输出上写出 XML 文件。 有没有办法用 JQuery 而不是 UpdatePanel 来做到这一点?

I'm using UpdatePanel to asynchronously call a button click event in a page that calls a method in another class which writes out an XML file on the output. Is there a way to do this with JQuery instead of UpdatePanel?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

装迷糊 2024-07-18 01:13:19

使用 jQuery 来处理点击事件。 然后使用 这种技术。 从那里您可以编写 XML 文件或执行任何您想要的操作。

Use jQuery to handle the click event. Then call a page method in the code-behind using this technique. From there you can write the XML file or do whatever else you want.

心的位置 2024-07-18 01:13:19

使用 jQuery 在没有更新面板的情况下执行 ajax 的一种简单替代方法是使用 ASP.NET 的内置机制,称为“页面方法”。 通过使用 [WebMethod] 装饰页面后面的静态方法,网站将生成一个生成的 javascript 函数,您可以使用 PageMethods.MethodName(param1, param2) 调用。 您仍然需要包含 ScriptManager 控件并启用如下所示的页面方法:

<asp:ScriptManager ID="theScriptManager" runat="server"
    EnablePageMethods="true" /> 

有关详细信息,您可以搜索“页面方法 ASP.NET AJAX”。

希望这可以帮助

A simple alternative way to using jQuery to do ajax without the update panel is to use a build in mechanism of ASP.NET called 'page methods'. By decorating a static method in the page behind with [WebMethod] the web site will have a generated javascript function you can call using PageMethods.MethodName(param1, param2). You will still need to include a ScriptManager control and enable page methods like this:

<asp:ScriptManager ID="theScriptManager" runat="server"
    EnablePageMethods="true" /> 

For more information you can search for 'Page Methods ASP.NET AJAX'.

Hope this helps

沫尐诺 2024-07-18 01:13:19

要在 jquery 中调用按钮单击事件,您可以这样做...

$("#MyButtonID").click();

按钮 html 看起来像这样...

<input type="button" id="MyButtonID" value="Press Me" />

To call a button click event in jquery you can do this...

$("#MyButtonID").click();

Where the button html looks like this...

<input type="button" id="MyButtonID" value="Press Me" />
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文