Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Replace UpdatePanel with JQuery

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?

like image 591
Malik Daud Ahmad Khokhar Avatar asked Jan 06 '09 07:01

Malik Daud Ahmad Khokhar


2 Answers

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.

like image 140
nshaw Avatar answered Oct 14 '22 21:10

nshaw


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

like image 26
Aleris Avatar answered Oct 14 '22 22:10

Aleris