Thursday, January 3, 2013

Redirect page on JavaScript alert in ASP.NET

Recently i needed to show a Javascript alert on a button click and after user click "ok" on alert box i need to redirect to another page. Below code did work for me.

Add the code in your button click event.

ScriptManager.RegisterStartupScript(Page, Page.GetType(), "ss", "<script>alert('My Message! '); location.href = '" + ResolveUrl("~/Default.aspx") + "'</script>", false);

No comments:
Write comments
Recommended Posts × +