views:

345

answers:

2

I want to auto submit my form and show the update progress area once it is submitted. I have tired adding 2 fucntions to the page:

window.onload=function(){
     __doPostBack('UpdatePanelId','');
}

and....

window.onload=function(){
     var btn = document.getElementById('buttonID');
     btn.click();
}

The page gets posted back to, but the progress area is not showing up. Any thoughts how I can handle this?

+1  A: 

Based on your further comments:

you have an UpdatePanel and SomeUploadControl outside of that panel. You want to show UpdateProgress when you cause a FULL POSTBACK from SomeUploadControl.

If the above assumptions are correct - I'm afraid you can't do what you want. The whole idea behind the UpdateProgress is to work on PARTIAL POSTBACKS.

I'm pretty sure the above is correct, but I might be mistaken.


Edited in light of your comment :)

try:

window.onload=function(){
     __doPostBack('buttonID','');
}

if this doesn't work - give more details on the problem you're trying to solve (why are you trying to cause the postback via javascript), and there might be a better way altogether.

roman m
I am using this control. I assumed my title gave that away. When the page is auto submitted, the UpdateProgress control is not showing up.
DDiVita
Nope.....The page gets submitted, but no progress area.
DDiVita
Well, I have an upload page and I am using a 3rd party upload control to handle the file upload. The control cannot be put into and updatepanel. The user will upload a list of e-mail addresses in CSV format. After the upload the file gets processed, but it can take a few minutes. My site makes use of the updateprogress control and it is pretty standard throughout the site. So, we would liek to keep it the same.
DDiVita
I forogot to add...After the upload is doen the site is redirected to a page to process the file. I have it auto submitting so the user doens't need to have any interaction.
DDiVita
wouldn't the upload control cause full page postback? from what i understand UpdateProgress won't show up on FULL POSTBACK.
roman m
That is why there is not updatepanel on the file upload page. I stated that. The updatepanel and updateprogress are on the file process page. Does that make sense?
DDiVita
The file upload page uplaods the file then redirects to the process file page. When the process file page loads the script in my questions is executed.
DDiVita
Sorry, my typing is so poor today. I am trying to do to many things at once ;)
DDiVita
I think you are correct. Never thought about that. It's strange, though that when I try the second method in my question it doesn't work. Hmmmm.....
DDiVita
This wasn't working because of the hierarchy naming convention: 'buttonID' was probably something like '$ctl1$ctl2$buttonID' or something. (I'm talking about the argument to __doPostBack)
Mike Gleason jr Couturier
A: 

I got it to work!!

Origianlly, I had my script running inside the ScriptManager client script block. I moved it outside of the script manager and added a timeout to the script. Here is what it looks like:

            Dim script As String = "window.onload = function(){" & vbCrLf
            script += "setTimeout('submitPage()',2000);}" & vbCrLf
            script += "function submitPage(){" & vbCrLf
            script += " var btn = document.getElementById('" & Me.btnProcess.ClientID & "');" & vbCrLf
            script += "btn.click();}" & vbCrLf    
                            ClientScript.RegisterClientScriptBlock(Me.Page.GetType, "autosubmit", script, True)
DDiVita
I didn't try this, but I guess i could have added the code to the Sys.Application.add_load
DDiVita