javascript alert() after postback c#

  • Thread starter Thread starter PH
  • Start date Start date
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.
 
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.
 
Hi, I just want to know that have you got an answer for this. Please
let me know. Thanks.

*-----------------------*
Posted at:
www.GroupSrv.com
*-----------------------*
 
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
*-----------------------*
 
Back
Top