Javascript successful message

  • Thread starter Thread starter Assimalyst
  • Start date Start date
A

Assimalyst

Hi,

I want to create a popup to notify a user that the server side process
has completed successfully. I intended to use a javascript alert to do
this, although ideally the icon should be different, but thats another
story . . .

Anyway, on successful completion of the process i use this piece of
code:

Response.Write("<script language=javascript>alert('Process completed
successfully!');</script>");

Which works OK, but if the page is refreshed afterwards the whole
server side process is launched again, resulting in the message box
appearing again.

Is there any way to prevent this? Or an alternative way to achieve the
same results?

Many thanks
 
Off Course. I deduct that you are using ASP.NET technologies. So first you
need to put this script (the response) into the Page_Load event. After this
put the response into an if statment and check the isPostBack Property of the
page ...
 
Thanks for the suggestion Raffaele, but it doesn't seem to work.

I have placed it in a if post back statement like so:

if (Page.IsPostBack)
{
Response.Write("<script language=javascript>alert('Process
completed');</script>");
}

So it is shows on postback, but when i refresh the page it seems to be
treated as a postback and runs the code again??

Am i missing something?

Any other suggestions?

Thanks
 
So it is shows on postback, but when i refresh the page it seems to be
treated as a postback and runs the code again??

Am i missing something?

Yes - refreshing the page performs the last action on that page, so if the
last action was a postback, refreshing the page will run the postback
again...
 
Very strange because you need to check in Page_Load event if the page is
PostBacked or not and show the Popup only 1 time ...
Mmm you can try to work with Session maybe and check it.
 
Yep, using sessions is my next plan thanks.

Yes - refreshing the page performs the last action on that page, so if the
last action was a postback, refreshing the page will run the postback
again...

Is there any way to refresh the page without running the last performed
task?

Thanks again.
 
Is there any way to refresh the page without running the last performed
task?

Not as far as I know, though you might get a more definitive answer on
microsoft.public.dotnet.framework.aspnet
 

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

Back
Top