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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Message Boxes AFTER PostBack

Miscellaneous

Message Boxes AFTER PostBack

by  akohli  Posted    (Edited  )
One way to do this is to declare a global variable of
type string in the code-behind and towards the end of
the method that caused the postback (I am assuming the
postback is required, in my scenario it was), set the
variable to a string that contains an alert e.g.
g_strPopUp = "alert('The procedure has completed
successfully.');"; //(The two semi-colons are not a
typo)

Now, in the aspx page, and this is an old classic ASP
technique, set the onload event for the page equal to
the global variable i.e.
<BODY onload="<%=g_strPopUp%>"

Since the server side code is executed prior to client
side code, the relevant HTML that will be emitted to
the browser will be -
<BODY onload="alert('The procedure has completed
successfully.');"

We did this on our project since we were transitioning
from a client-server PowerBuilder app to an ASP.NET
app, and the users were used to/preferred pop-ups as
opposed to the standard ASP.NET methodology of using
labels. Hope this is of help to you and it would be
interesing to see if this is, if you will, robust
enough to hold up under other scenarios. We have used
this in conjunction with window.close() as well and
that worked just fine too.
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top