How to use Redirection from iframe in asp.net

Redirection from iframe in asp.net

protected void btn_Submit_Click(object sender, EventArgs e)

{

//your code to verify username/password will come here

ScriptManager.RegisterStartupScript(this, this.GetType(), "redirect", "if(top!=self) {top.location.href = 'next-page.aspx';}", true);

}

Note:-
In case if this code is not working properly in IE9 then you have to give the absolute path of targeting webpage such as

if(top!=self) {top.location.href = 'https://www.yourwebsite.com/next-page.aspx';}", true);

Using the server side onClick event of asp:button, we are redirecting user to another page but now page will not be open inside the iframe because the javascript code that we have written in the server side onClick event of asp:button will take care that user must be redirected to next page within parent window rather than IFrame

0 comments:

Post a Comment