I had a similar requirement and was able to use this technique successfully. However I'm not able to get the UpdateProgress control to function. Even when I pasted your code into a blank aspx page the UpdateProgress text was not showing. I've gotten it
to work with update panels before, but not when using this technique. Any insite?
hi, I've re-tested the code and apparently the UpdateProgress is not working as you've mentioned. I'm not sure what has changed since then and now. I notice in my posting that I was quite insistent and sure the code works. I'm as stupefied as you are, but
it's best to move on and look for a better solution. Trying to figure why this control is not working is a lost investment, simply because this control brings very little to the table and it's not very flexible that I myself ended up rewriting from scratch
for my own usage.
Really, all you need is a div in the page and then show/hide it in the apposite handlers triggered during an async postback. This is also what the control does in the background while limiting you in how it is consumed.
I have added the modifications you need below :
<script type="text/javascript">
Sys.WebForms.PageRequestManager.getInstance().add_pageLoaded(pageLoaded);
Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(BeginRequestHandler);
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);
function pageLoaded(sender,args) {
var gridView1=$get('<%= GridView1.ClientID %>');
var button1=$get('<%= Button1.ClientID %>');
if(gridView1===null)
button1.click();
}
function BeginRequestHandler(sender,args) {
var elem=args.get_postBackElement();
if(elem.id=='<%= Button1.ClientID %>') {
var updateProgress1=$get('<%= UpdateProgress1.ClientID %>');
updateProgress1.style.display='';
}
}
function EndRequestHandler(sender,args) {
var updateProgress1=$get('<%= UpdateProgress1.ClientID %>');
updateProgress1.style.display='none';
}
</script>
As you can note from above we are doing what the updateprogress control fails to do on it's own. At this point, you can very well use a normal div and show/hide it instead of the updateProgress as I am doing above.
alessandro
Contributor
6800 Points
1105 Posts
Re: how to load gridview after the page is completely loaded?
Nov 12, 2009 12:01 AM|LINK
hi, I've re-tested the code and apparently the UpdateProgress is not working as you've mentioned. I'm not sure what has changed since then and now. I notice in my posting that I was quite insistent and sure the code works. I'm as stupefied as you are, but it's best to move on and look for a better solution. Trying to figure why this control is not working is a lost investment, simply because this control brings very little to the table and it's not very flexible that I myself ended up rewriting from scratch for my own usage.
Really, all you need is a div in the page and then show/hide it in the apposite handlers triggered during an async postback. This is also what the control does in the background while limiting you in how it is consumed.
I have added the modifications you need below :
<script type="text/javascript"> Sys.WebForms.PageRequestManager.getInstance().add_pageLoaded(pageLoaded); Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(BeginRequestHandler); Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler); function pageLoaded(sender,args) { var gridView1=$get('<%= GridView1.ClientID %>'); var button1=$get('<%= Button1.ClientID %>'); if(gridView1===null) button1.click(); } function BeginRequestHandler(sender,args) { var elem=args.get_postBackElement(); if(elem.id=='<%= Button1.ClientID %>') { var updateProgress1=$get('<%= UpdateProgress1.ClientID %>'); updateProgress1.style.display=''; } } function EndRequestHandler(sender,args) { var updateProgress1=$get('<%= UpdateProgress1.ClientID %>'); updateProgress1.style.display='none'; } </script>As you can note from above we are doing what the updateprogress control fails to do on it's own. At this point, you can very well use a normal div and show/hide it instead of the updateProgress as I am doing above.
This is also by far the most flexible solution.
Have a good day,