Is there a way to trigger an updatepanel without a click event? - asp.net

I'm trying to load parts of a page at a time instead of doing all my calculations in the onLoad page event, then displaying all the calculations at once.
I think one of the ways to mimic a faster loading page is to separate parts of the page into updatepanels (correct me if I'm wrong in this approach). As such, I'm wondering if there is a way to execute some code in the onLoad event, display that on the page, then continue some other work in updatepanels and load those as they get completed.

UpdatePanels are a poor implementation of ajax. Since only a section of the page is being updated, it is easy (too easy) to think that you have reduced the execution time of your page. An UpdatePanel performs a postback and as such executes the entire life cycle of your page (lamely put, it will execute the PageLoad for your page and every usercontrol on your page not just the ones that are in the UpdatePanel). Unless you put lots of if !Page.IsPostBack in your code, you could actually end up slowing your application down. Also, since it is a postback, it will submit the runat='server' form that is on your page and submit every input (not just the stuff in the update panel) to the server, which means you aren't saving anything on payload and bandwidth by using an update panel.
to answer your question though, you just need to call __doPostBack('updatepanel1', ''). reference http://encosia.com/easily-refresh-an-updatepanel-using-javascript/

You can call the .Update method on the UpdatePanel. Set the UpdateMode to be Conditional and handle all of the Update panel updating by hand in code.

Related

Textbox autopostbacks

I have a custom asp.net user control which has an update panel in it. In this update panel i have all the controls and content that are shown to the user. Amongst these controls there are two textboxes, which have AutoPostback = true. This is because when their value is changed, the structure of the page changes accordingly. This works as required, but when I modify the two textboxes in quick succession, the first autopostback works while the second one doesn't fire. It seems that while it is doing the first postback, any other attempted postbacks will be ignored. How can I work around this?
This behavior is by design. The usual approach is to use UpdateProgress control that disables the user input on the page while the postback is in process.
Alternatively you could add your own onchange event handlers that call __doPostBack() more intelligently (by using timers etc.) to avoid this problem for your specific scenario. You could also try aborting any postback is process before submitting a new one.
A resource that might be useful: http://www.dotnetcurry.com/ShowArticle.aspx?ID=176

how to cause refresh to ASP.net Page when page Postback

When the ASP.net Page is Postback the controls inside the table is disappear,
but when i click on button that has that code which cause transfer to the page:
Server.Transfer("~/Admins/EditUsers.aspx");
all controls appear easy with no problems.
Then,is there is need to make refresh to the page, or what can i do?
Thanks
A postback already performs a page refresh automatically.
If controls are disappearing, that suggests that you might not be creating them on the postback. Note that tables do not store their contents in ViewState. Is there any chance you are testing for IsPostBack in your page Load handler? If so, you must recreate the table on every load, whether a postback or not.
Beyond that, you'd probably need to provide a bit more specific information.

Problem aborting ASP.Net UpdatePanel or Telerik RadAjaxPanel

I've been trying to solve a problem. I have a rather slow loading set of nested datarepeaters that take a couple minutes to fully render. I need to have a cancel button.
First I tried a simple updatepanel with a cancel button in an updateprogress that performed an abortPostBack. It would hide the updatepanel but wait until the datarepeater was done before you could do anything on the page.
We have the Telerik AJAX controls so, hoping they're more advanced, I've now wrapped it up in a RadAjaxPanel. This seems to have the same issue. I've even tried firing an ajaxManager.ajaxRequest back to the server and setting a bool to try and abort the databinding, but that event isn't caught by the server until the databinding completes.
Any ideas on how to get a responsive cancel to a large set of nested datarepeaters?
I think that you can cancel the ajax request from Telerik ajax panel or ajax manager only before it reaches the server, i.e. inside the OnRequestStart client event of both by setting args.set_cancel(true).
Dick

Can I avoid having an UpdatePanel that kills viewstate?

I selection page that has a gridview that presents the user with a list of data items that they can click on to "drill into" - redirecting them to the data maintenance page.
Because the list can get long, we have a series of check boxes and drop-down lists at the top that act as filters.
We just implemented an UpdatePanel with an UpdatePanelAnimationExtender so that when the page made long trips back to the databse, they would get a nice "Processing..." pop up.
Problem is, this seems to break the viewstate on the drop-down lists and check boxes. Now, when they go to the 'detail page' and hit the BACK button to get back to the 'selection' page - the selected values in the checkboxes and drop-downlists are back to their initial defaults. The lists are still populated, but they 'forgot' what they had when the user clicked to the data maintenance page.
I took out the .aspx code for the UpdatePanel and the animation extended and retested and everything worked perfectly. So, apparently, the UpdatePanel and/or the AnimationExtender doesn't play nice with the viewstate.
Is there a way I can stop the UpdatePanel's actions from, in effect, zeroing out the '.SelectedValue" properties?
First I would remove your "filtering" controls from the UpdatePanel. Assuming that the data for these controls are valued on Page_Load, they do not need to be refreshed every time the filter is applied to the GridView. Only the GridView is being refreshed, so it's likely that it is the only control that should be contained in the UpdatePanel.
Each of the filtering controls can be added as a trigger for updating the UpdatePanel by declaring them in the section of the UpdatePanel control. Or, if the filtering process is invoked by a "submit" like button, that would be the control to be declared in the section. This should retain the values of the filtering controls in the browser's cache.
You can also try Nikhil Kothari's UpdateHistory control (Nikhil has an excellent blog, btw) which will save the contents of the UpdatePanel as history entries in the browser's history list.
EDIT: FYI, UpdatePanel does not "kill" ViewState. The ViewState is transmitted back and forth via the UpdatePanel's update mechanism, often causing performance issues if the ViewState is excessively large. What you're seeing is the browser's history cache not storing the values that have been updated on successive callbacks. The above techniques should help.

AJAX Partial Page Load?

I have a page results page (you get there after submitting your search query elsewhere) whit a whole bunch of gridviews for different type of data objects.
Obviously, some of the queries take longer than the others. How can I make each gridview render as soon as it has the data it needs?
This has been tricky for me because it must work on a postback as well as a pageload. Also, the object data sources just fire automatically on page load/postback; I'm not calling any methods programatically to get the data. Will I have to change this?
#Gareth Jenkins
The page will execute all of the queries before returning even the first update panel, so he won't save any time there.
The trick to do this is to move each of your complex gridviews into a user control, in the user control, get rid of the Object DataSource crap, and do your binding in the code behind.
Write your bind code so that it only binds in this situation:
if (this.isPostBack && ScriptManager.IsInAsyncPostback)
Then, in the page, programaticly refresh the update panel using javascript once the page has loaded, and you'll get each individual gridview rendering once its ready.
Could you put the DataGrids inside panels that have their visibility set to false, then call a client-side javascript function from the body's onload event that calls a server side function that sets the visibility of the panels to true?
If you combined this with an asp:updateProgress control and wrapped the whole thing in an UpdatePanel, you should get something close to what you're looking for - especially if you rigged the js function called in onload to only show one panel and call a return function that showed the next etc.

Resources