javascript alert() after postback c#

P

PH

Does anyone know how to have the pop-up javascript alert,

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

, pop-up after the page has been posted back? I am pressing a button,
validating data and then wanting to simply pop-up an alert if say the
login is empty. When I click the button though the page is blank but
the pop-up is there.
 
J

James Musson [MSFT]

Hi PH

The Page provides a method, RegisterStartupScript to do this. For example:

Dim startupScript As String
startupScript = "<script
language=""javascript"">alert('Hello!');</script>"

If IsPostBack Then
RegisterStartupScript("startup", startupScript)
End If

HTH

James.
 
R

rajandsa

Hi, I just want to know that have you got an answer for this. Please
let me know. Thanks.

*-----------------------*
Posted at:
www.GroupSrv.com
*-----------------------*
 
R

rajandsa

Using RegisterStartupScript I registered script on page which has
alert on it when the validation fails on the page. After validation
passes I am redirecting to another page. After that when I click a
back button on the browser, that validation pop up message box
appears on the page. How can I prevent this? I know why it is
happening bacause, the page is not completly submitted due to
redirecting page. Please let me know if you can help. Thanks.

*-----------------------*
Posted at:
www.GroupSrv.com
*-----------------------*
 

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