Replace UpdatePanel with JQuery

徘徊边缘 提交于 2019-12-18 10:45:26

问题


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?


回答1:


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.




回答2:


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




回答3:


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" />


来源:https://stackoverflow.com/questions/415711/replace-updatepanel-with-jquery

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!