Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HtmlInputFile 1

Status
Not open for further replies.

figler

Programmer
Dec 26, 2001
155
US
I am using the htmlinputfile control to upload files.

The web page that is used to upload files into a directory also displays a list of the files in that directory. I refresh that list on page_load (regardless of page.ispostback value) so I thought that the list would always be up-to-date.

Of course, that's not the case -- it looks like the actual file upload executes in a different process so that the page may load before the file upload is complete.

How can I halt code execution until the file is uploaded? Or -- even better -- give the user some feedback as to the status of the upload and then reload the page once the file is uploaded?

Thanks. -Brad
 
populate the list on the page_prerender event

all of your other events will have fired by that point, and it's your last chance to change page content before it's buffered to the client.

protected sub page_prerender(o as object, e as eventargs) handles mybase.prerender
'populate list here
end sub

should fix you right up

:)
paul
penny1.gif
penny1.gif
 
Link9:

No wonder you are the "top expert" :)

Now maybe someone can explain to me why this works? Like when exactly does the file upload take place in the sequence of ASP.NET events?... from what Link9 wrote (and, by the way, his solution worked just fine) it would seem that the file upload takes place after page_load and before page_prerender. But that just doesn't make sense to me -- seems like the oncommand event of the 'upload' event should be handled *before* moving on to page_load. Can anyone explain??

Thanks. -Brad
 
Not sure that I can explain why, however I can tell the sequence in which things are executed.

1. The Page_Init is run.

2. The Page_Load is run.

3. Any event handlers called are run.

4. As Paul said the last to run is the Page_PreRender

If you keep this sequence in mind when you are codeing it often will makes things simpler. That'l do donkey, that'l do
[bravo] Mark
If you are unsure of forum etiquette check here faq796-2540
 
I'm stumped...

login.aspx authenticates user and sets a the "admin" cookie to "true" before redirecting (response.redirect) to main.aspx.

the problem:
i load controls on main.aspx slightly differently depending on the value of the "admin" cookie. if a user enters his password succesfully on login.aspx, she is redirected to main.aspx but sees controls as they should be rendered for a non-admin. once the user clicks anything on that page (forcing a postback) the controls are rendered appropriately.

i have executed the rendering procedure in both page_load (originally) and page_prerender but it did not help.

is there a way to force a refresh when i do response.redirect or am i missing something more fundamental about order of operations or something else? help is *much* appreciated!

Thanks!

-Brad
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top