Postback woes

C

Clive Lumb

Hi,

I am not at all an expert in html & asp.net and I am runnin ginto a problem
with a very simple web application.

It is a page with a datagrid showing some data and a fileupload control that
allows the user to upload a file.

Everything works fine... except - when a user has uploaded a file, if he
then later refreshes the page to see if the database stuff has changed the
file gets uploaded again.

Now I suspect that this is something to do with postbacks - but I must admit
that I cannot make head nor tail of the Microsoft help on this.

Basically all I need to do is upload the file, refresh a label saying "your
file xxx has been uploaded" and then "clear" the fileupload so that
subsequent refreshes do not trigger another upload.

Help please? And in words of no more than two syllables.

TYVMIA
 
P

Phill W.

Clive said:
Everything works fine... except - when a user has uploaded a file, if he
then later refreshes the page to see if the database stuff has changed the
file gets uploaded again.

Remember how a web application works.
The client browser sends a request to the server, which does whatever it
has to do (in this case upload a file and display some results) and then
sends back a response made up of a block of Html.

If the user hits Refresh, then the browser simply submits the /same/
request which asks the web server to do the same things, all over again.
Now I suspect that this is something to do with postbacks - but I must admit
that I cannot make head nor tail of the Microsoft help on this.

It's not really a PostBack problem; Refresh really /is/ a
"do-it-all-again" operation.
Basically all I need to do is upload the file, refresh a label saying "your
file xxx has been uploaded" and then "clear" the fileupload so that
subsequent refreshes do not trigger another upload.

I would suggest you need to divide this process in two - one page to
upload the file and another to do the display and which the user can
Refresh to their hearts content.

Mind you; there may well be a better way; I'm an ASP.Net
Middle-Through-er as well ... ;-)

HTH,
Phill W.
 
C

Clive Lumb

Thanks to both of you.

I have added a "refresh" button that calls
Page.Response.Redirect(Page.Request.Url.ToString(), True)

This seems to send a new "get" rather than a refresh

Cheers
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top