Using update panel in AJAX a good practice in asp.net ??? ... or one should code himself for AJAX for each and every control using HTTP-Object ? In which scenarios are the above two strategies used ???
The Update Panel is a good thing in that it allows the developer to code AJAX very simply. It has a lot of overhead, though, and I would not recommend it as a solution in most (if not all) cases.
Look into ASP.Net AJAX for a good way to get started using AJAX. Its fairly simple, robust, and flexible. (It doesn't prevent you from using the update panel either).
Related
I have a solution that uses Accordian and tab controls, amongst others.
Is it worth swapping these out and use the jQuery controls instead?
What are the benefits? Is it best practice to load one tab at a time with data?
There are obviously benefits to using both, but in my experience if you are using ASP.NET then you are going to find the (I'm assuming you meant Ajax Control Toolkit) the ASP.NET controls better if you have a requirement for data-binding or have a high tendency to utilise your server execution time a lot.
IMO if the current controls meet your requirements then there isn't a breaking reason to switch to the jQuery controls, some ASP.NET server controls that provide Ajax functionality can be quite heavy-weight and cumbersome, but I've found controls like the Accordion to fit my needs perfectly, and wouldn't see a need to switch unless it wasn't flexible enough.
I had to make this swap in some test on my projects, from ASP.NET Ajax controls to jQuery controls, and my only issues was the UpdatePanel's.
ASP.NET take care the UpdatePanel messages (when you make asynchronous calls), but if you going to change it with jQuery you need to take care this updates by yourself - if you use UpdatePanel.
Update.
I agree with the comments for the UpdatePanel. I was working on a project, that had already many upadtePanels, and we just started to change some things to see what and how. If you build it up from the beginning I agree that it's better to avoid UpdatePanel, and do it with jQuery.
I'm working on replacing an existing web grid in an ASP.NET web application, with a new implementation. The existing grid is powerful, but not flexible enough. It also brings with it all kind of frameworks we don't like to have on our web pages.
While looking into existing options I noticed I can break the available solutions into two main approaches. The older approach is represented best by the ASP.NET GridView. This is a classic ASP.NET control that generates the needed HTML on the server, based on a given set of data. The newer approach is depending on client side rendering, mainly with jQuery. A good example would be jqGrid. Only the data is sent to the client (Usually with JSON or XML)
In the GridView case, if I want an AJAX behavior, I would have to implement it with something like an update panel.
Is there a definitive choice I should make?
Is there a good chance of achieving the same snappy behavior I get with jqGrid (even with many records), with server side rendered controls?
Is there some hybrid implementation incorporating both approaches?
There is no definitive choice you should make, but it's worth noting
that changing to client-side AJAX controls is a pretty big paradigm
shift that will require you to rethink how you do nearly everything
with the grid.
Going half-way (by using a server-side control such as GridView
in an UpdatePanel) will likely improve the user experience, since
the page will still be visible and responsive while it's updating. But
the UpdatePanel-style is still clunky compared to the new client-only
grids, because this technique sends all the page's form data when it posts back
(including all that ViewState in the GridView, if ViewState is turned
on). One brief note of caution: GridView is not compatible with
UpdatePanel when GridView.EnableSortingAndPagingCallbacks is set to true.
I haven't used any of they hybrid implementations (such as Coolite's Ext wrappers for .NET), but they are out there. There was at least one good SO discussion about this topic and the different grids available here.
I am also evaluating jgGrid vs. Gridview. I am just interested in the performance and efficiency of the grid. Even though jqGrid has a bit learning curve, I can invest some time in learning if it can provide great improvement in performance when compared to gridview. Can any expert throw more light on this topic?. Thank you very much.
I recently discovered the client-side methods of some of the controls in the Microsoft ajax control toolkit. For instance, with the TabContainer, I can do something like this:
$find('tabsEditJob').get_tabs()[1].set_enabled(true);
without having to resort to server side code. Is there a way to do this in your own custom user controls without too much work?
UPDATE: I was going to implement show and hide methods: although setting display to none would probably work just fine, they would prefer an explicit method. I know that the ajax control toolkit controls have a set_visible method. Do user controls get this too?
The approach the ajax control toolkit is a managed approach, so you should check out this walkthrough as a good overview of what it is and how you create it: http://www.asp.net/learn/Ajax-Control-Toolkit/tutorial-49-cs.aspx
There is both a server-side and client-side piece; it can be confusing at first, but it isn't that difficult to setup once you are used to it. But it does require some reading up on it first and a some considerable planning.
I've built a few of my own, and you have to think about all the interations you want to include and at what point certain pieces of code should run, all of the events, etc.
HTH.
What are the advantages and disadvantages of using Ajax update panels in ASP.NET application. Is there any alternatives available to avoid the use of Ajax update panel?
Advantages:
Easy to use and configure (Well, I don't know of any other advantages!)
Disadvantages:
See here and here
Now for the best part, the alternatives:
Use jQuery's built in support for Ajax to make GET/POST Ajax calls, it's very simple (simpler than the update panel I would say), and absolutely compatible with most browsers!
An example of using one of the many easy ways jQuery provides for doing Ajax calls:
$('#anotherContainer').load('/Home/RegularAjaxResource');
This would simply call a server resource (RegularAjaxResource in this case) and display it's returned data on an UI element with id anotherContainer
I agree with 7alwagy, except just want to add an important point.
You have to use the UpdatePanel if you want to update/change controls AND still work within the Webforms Postback model of state control, in particular, Viewstate.
For example:
if you explicitly use JS to update the values of a DropDownList control on the client, and you're using the built in Webforms Postback model, the changes you've made won't be picked up.
Essentially, if you're relying on the built in Viewstates, then you have to use the UpdatePanel. You can technically not use it, but you'll really have to fight agaisnt the framework to get things done.
If you're not relying on Postbacks or Viewstates, then you totally don't need the UpdatePanel.
I seriously cannot think of 1 advantage of using updatepanels. They are grief and i found that out the hard way.
They're usable only for the most trivial ajax effects and if you're going to do any data retrieval or database lookups they have a huge problem in scaling up. UpdatePanels are frustrating and not a long time I have shared the updatepanel grief here, here, here and here.
If that's not enough to convince you not to use updatepanel then nothing will.
I agree that update panel is evil and dangerous but in some cases you may want to use it, instead of other options.
The page has few asp.net controls, and less viewstate.
The page html is not too big.
The time is limited to finish the task.
The performance is not the first concern.
Want to keep the sate of controls with postbacks.
Have a lot of server side events you want to fire.
Advantages:
Easy to implement
No need to write javascript in the client
Disadvantages
Uses more bandwidth since all view states are transferred
Element which is supposed to fire the ajax call should be inside the update panel. It is not practically possible all the time
Data outside the update panel is not sent to the server which may be needed for further processing.
In practice developer cannot pre-determine what all data is needed to include in the update panel
I really like the looks of jQuery UI and I'd love to integrate it into my ASP.NET Web Applications. I like the themes and how easy it is to use the widgets. I'm currently using AJAX Control Toolkit controls like the Calendar and ModalPopup. I'm hoping to replace them with the DatePicker and Dialog widgets, but I hear they have issues with UpdatePanels. There are workarounds for these issues, but I wonder, is it worth it?
Which leads into my question(s):
Has anyone had luck using jQuery UI widgets exclusively (instead of AJAX Toolkit Controls) in an ASP.NET Web Application that occasionally uses UpdatePanels?
Are there any best practice resources for getting jQuery UI and UpdatePanels to play nice?
Update:
Based on the answers so far, it seems that the best thing to do is replace UpdatePanels with $.ajax and PageMethods. That should allow me to use jQuery UI without any issues and also improve my AJAX performance.
No, it's not worth it. If the toolkit's calendar and modalpopup extenders are working for you, then just hold on to them.
In future projects, stay away from asp.net ajax and use jQuery exclusively. This way you wont run into any of the updatepanel problems. ASP.NET 4.0 Webforms are going to make using jQuery much easier in the past, because you will have more control of how controls get named when they are rendered to HTML.
We use Microsoft AJAX (only using UpdatePanels) and jQuery and all works great.
Using UpdatePanels makes all UserControls, Postbacks, Viewstate etc work as you would expect with the UI enhancements of jQuery. There are a few things to learn in getting them to work together and until we find an alternative we will continue to do this. We think its worth it.
I would be keen to see how UpdatePanels can be easily replaced with jQuery, but I expect one would need to write additional code for each UpdatePanel replacement, rather than letting asp.net handle things? Are there any articles out there that demonstrate replacing UpdatePanels that contain asp.net controls and UserControls with events etc?
I'm working on a project with a lot of UpdatePanel and jQuery, things just work fine.
Yes, it is a period when you need to learn, to make things work.
If you have a lot of UpdatePanels and you don't want to remove them then this is understandable, and using jQuery is just improving the UI, so it's not going to much worse.
Also jQuery has functionalitys related to AJAX,so you can make elegant client side coding with jQuery which is not related to Design and ui stuff.
I think if you search for jQuery and Ajax on the internet you will find a bunch of good examples, and fine techniques to both technologies together.
PS:
Remenber that UpdatePanel is evil in sort of way when you are using in an inappropriate way.
UpdatePanel is (and generally AJAX) is very customizable, make time for yourself to optimize it
Good luck!