Monday, March 26, 2012

Trigger DynamicPopulate on page load

I currently have a page that takes a very long time to load. What I want is for the page to load up content-less (just the master page), and then have a UpdatePanel load the actual content dynamically instead of having a 3/4 second load time.

I've tried hiding the UpdatePanel and using a DynamicPopulate extender to set the UpdatePanel to visible, but I can't find a way to trigger the DynamicPopulate extender after the page load.

Has anyone got any ideas how I can do this?

Thanks,
Weiran.

weiranz:

What I want is for the page to load up content-less (just the master page), and then have a UpdatePanel load the actual content dynamically instead of having a 3/4 second load time.

We recently published two videos that address this very question.

How Do I: Implement the AJAX Incremental Page Display Pattern?

How Do I: Implement the Incremental Page Display Pattern using HTTP GET and POST?

Each video provides sample code in C# and Visual Basic. So you should be able to watch the videos, download the code, and achieve your goal of having the page dynamically load content.


I do have a followup questions on these examples:

Both examples use either a web service or a get/post to retrieve plain html which is filled into a div section. So the content is, even though dynamically populated, static. How would I trigger a dynamic populate of an update panel on page load? My scenario is the following:

I have a page that contains a search box with a button and a GridView in an UpdatePanel. The typical usage is that the user enters something in the textbox and clicks search, then the query will be executed and the updatepanel refreshed with the filled GridView, showing a progress indicator while working. This works very well...
Now I want to link to this particular page and pass in a search term via the querystring. Easy enough, in OnPageLoad I pickup the term(s) from the query string, execute the query and directly show the page with the filled GridView. This works, but may be bad if the query takes along time, the page will not show until the result is available. What I would like to do is to show the page and on page load doing a postback with the parameters passed in from the querystring.

Is there an easy way to kick off such a pseudo postback that does not trigger a full postback on page load?

No comments:

Post a Comment