i have asp.net page that is opened inside an iframe. How to redirect to exceptionmessage.aspx page if any error occurs? Currently the page redirected is displayed inside the iframe. I want to close the iframe and redirect to exceptionmessage page.
1 Answer
you can use this by placing your code snippet in try catch block
if your code gets some error than in your catch block call a js function in that redirect to your error page.
try
{
//your code
}
catch
{
Page.RegisterStartupScript("RefreshParent","<script language='javascript'>RefreshParent()</script>");
}
<script language="javascript">
function RefreshParent()
{
window.parent.location.href = "myErrorPage.aspx";
}
</script>
you can do some thing like this.