i wud like 2 display a alert message with a Ok button.and wen the user clicks ok he must b redirected 2 a specified page.i tried in the following manner bt in dat case it only redirects n does display the message.

Response.Write("<script> alert('message!!');</script>")
Response.Redirect("webform1.aspx")

any suggestions

i wud like 2 display a alert message with a Ok button.and wen the user clicks ok he must b redirected 2 a specified page.i tried in the following manner bt in dat case it only redirects n does display the message.

Response.Write("<script> alert('message!!');</script>")
Response.Redirect("webform1.aspx")

any suggestions

hi,
U can use OnClientClick property of the button to display the alert message
eg: OnClientClick="alert('Message!');"
and in the code behind, u can redirect to ur page

Use the Following Code:
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Public Shared Sub ShowAlertMessage(ByVal msg As String)
'Display javascript-alert
Dim page As Page = TryCast(HttpContext.Current.Handler, Page)

If page IsNot Nothing Then
msg = msg.Replace("'", "\")
ScriptManager.RegisterStartupScript(page, page.GetType(), "err_msg", "alert('" & msg & "');", True)
End If
End Sub

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
CALL THE CODE BY FOLLOWING WAY...
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
ShowAlertMessage("Your Error Message Here")

This article has been dead for over six months. Start a new discussion instead.