Asp.net handles exception inside iframe

I have an asp.net page that opens inside an iframe. How to redirect to exceptionmessage.aspx page if any error occurs? The redirected page is currently displayed inside the iframe. I want to close the iframe and redirect to the exceptionmessage page.

+3
source share
1 answer

you can use this by placing a piece of code in a try catch block

if your code gets some error than in your catch block, call the js function in this redirect to the 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 something like this.

+2
source

All Articles