alert dont display
-
hi guys i have a website that in button execute some methods and with this code response.write("alert(\"messge\") "); and then response.redirect("a.aspx"); now alert do not display whats problem ? thanks a lot
If I understand, when a user click on the button. In the event you have:
void btnTest_Click(object sender, EventArgs e)
{
Response.Write("<Script>alert('messge') </Script>");
Response.Redirect("page2");
}in this case, the redirection is make and the page with the button cannot display the alert. For resolve you problem try:
<script language="javascript">
function onButtonClick()
{
alert("message");
document.location = "http://www.google.fr";
}
</script><asp:Button ID="btnTest" runat="server" OnClientClick="javascript:onButtonClick()" />
If you have some thing to execute in the event, you can make this
void btnTest\_Click(object sender, EventArgs e) { Response.Write(@"<Script> alert('message'); document.location = 'http://www.google.fr'; </Script>"); }
modified on Tuesday, November 30, 2010 8:04 AM
-
hi guys i have a website that in button execute some methods and with this code response.write("alert(\"messge\") "); and then response.redirect("a.aspx"); now alert do not display whats problem ? thanks a lot
If you're doing a Response.Redirect("someUrl"). The redirect will be done on the server side. That means you're transfering control to the execution of page a.aspx. The former writing of that script tag is hereby irrelevant. Cheers Manfred