asp.net 4.0: Using jQuery in place of UpdatePanels?
-
Hello. I'm beginning a new asp.net website (using asp.net 4.0) and I want to try implementing some better coding practices to keep the site's code "cleaner". From what I've read, updatepanel's bring along with them, a lot of unnecessary code, so my 1st plan is to avoid using them entirely. So, I was planning on using only javascript (i.e. jQuery) to handle the same functionality of that of an upatepanel but I'm unsure of how to implement this functionality. In particular, how do I get jQuery to handle the postbacks to the server in order to communicate with asp.net server side controls? Does anyone know of any tutorials on this in asp.net 4.0? I've been able to find older tutorials using asp.net 3.5 (which looks to be quite a bit of javascript code to handle the equivalent of an updatepanel), but wasn't sure if 4.0 implemented any more efficient approaches. Thanks.
-
Hello. I'm beginning a new asp.net website (using asp.net 4.0) and I want to try implementing some better coding practices to keep the site's code "cleaner". From what I've read, updatepanel's bring along with them, a lot of unnecessary code, so my 1st plan is to avoid using them entirely. So, I was planning on using only javascript (i.e. jQuery) to handle the same functionality of that of an upatepanel but I'm unsure of how to implement this functionality. In particular, how do I get jQuery to handle the postbacks to the server in order to communicate with asp.net server side controls? Does anyone know of any tutorials on this in asp.net 4.0? I've been able to find older tutorials using asp.net 3.5 (which looks to be quite a bit of javascript code to handle the equivalent of an updatepanel), but wasn't sure if 4.0 implemented any more efficient approaches. Thanks.
JavaScript, or JQuery more specifically, is independent of any version or flavor of .NET, so if you find one example it should apply to all. In this situation you don't use JQuery to do any postback. You would use JQuery to make an AJAX call to a server resources, perhaps a PageMethod, then upon return, handle any page updates necessary via the DOM. This is one example, there are many more available. http://encosia.com/using-jquery-to-directly-call-aspnet-ajax-page-methods/[^]
No comment
-
Hello. I'm beginning a new asp.net website (using asp.net 4.0) and I want to try implementing some better coding practices to keep the site's code "cleaner". From what I've read, updatepanel's bring along with them, a lot of unnecessary code, so my 1st plan is to avoid using them entirely. So, I was planning on using only javascript (i.e. jQuery) to handle the same functionality of that of an upatepanel but I'm unsure of how to implement this functionality. In particular, how do I get jQuery to handle the postbacks to the server in order to communicate with asp.net server side controls? Does anyone know of any tutorials on this in asp.net 4.0? I've been able to find older tutorials using asp.net 3.5 (which looks to be quite a bit of javascript code to handle the equivalent of an updatepanel), but wasn't sure if 4.0 implemented any more efficient approaches. Thanks.
asp.net is not really a factor using jquery, unless you populate a control with data, and alter the data with jquery, and then try to post it back to the server. Asp.net will think that the page has been tampered with, and will generate an error. So of anything, you really have to know asp.net really well, in how it deals with postbacks. So start small with pages that don't postback or forms, and move on to as you get more confident. FYI: I got feed up with asp.net AJAX Toolkit, and decided to stop using it, replacing it with JQuery. The journey was long, but so far after 4 months of testing, it was well worth it. I get very few complaints now, and users claim that the programs are easier to use now. Actually now that I think about it, I did get rid of many update panels as well, but not for the reason you claimed. I got rid of them because I needed smoothness or animation to transition from 1 stage to another, while showing progress, but not in the form of a wheel, but in the animations themselves. This changed the users perception of nothing happening fast enough due to bandwidth restrictions to something is happening. So now I don't get the user pressing the button over and over. Here is the 10th Program I wrote with your idea, no AJAX or Update panels, pure asp.net controls and Jquery. It took 2 weeks to write, but works pretty good. I think the jquery is over 5,000 lines. [^Pure Jquery and asp.net controls from server side]
-
asp.net is not really a factor using jquery, unless you populate a control with data, and alter the data with jquery, and then try to post it back to the server. Asp.net will think that the page has been tampered with, and will generate an error. So of anything, you really have to know asp.net really well, in how it deals with postbacks. So start small with pages that don't postback or forms, and move on to as you get more confident. FYI: I got feed up with asp.net AJAX Toolkit, and decided to stop using it, replacing it with JQuery. The journey was long, but so far after 4 months of testing, it was well worth it. I get very few complaints now, and users claim that the programs are easier to use now. Actually now that I think about it, I did get rid of many update panels as well, but not for the reason you claimed. I got rid of them because I needed smoothness or animation to transition from 1 stage to another, while showing progress, but not in the form of a wheel, but in the animations themselves. This changed the users perception of nothing happening fast enough due to bandwidth restrictions to something is happening. So now I don't get the user pressing the button over and over. Here is the 10th Program I wrote with your idea, no AJAX or Update panels, pure asp.net controls and Jquery. It took 2 weeks to write, but works pretty good. I think the jquery is over 5,000 lines. [^Pure Jquery and asp.net controls from server side]