Reputation: 4464
I am new to asp.net and hence stuck at a very simple point. I am trying to open a popup window from an existing browser window using below code :
string url = "D13.aspx";
string s = "window.open('" + url + "', 'popup_window', 'width=300,height=100,left=100,top=100,resizable=yes');";
ClientScript.RegisterStartupScript(this.GetType(), "script", s, true);
D13.aspx is an empty aspx page. There are no console errors or popup getting blocked. But the popup window is not opening up. Is there anything to be done in javscript or this code alone is enough? Any suggestions?
Upvotes: 2
Views: 19789
Reputation:
By default your browser blocks pop-up enable popup in your browser then run it, will work fine.. I have checked it with chrome. you your chrome is blocking that at right hand side of window corner there will be a red alert showing that popup blocked you can allow from there...
Upvotes: 0
Reputation: 10320
I have tested the below and found that it works (IE 11):
protected void OpenPopUp_Click(object sender, EventArgs e)
{
string url = "D13.aspx";
string s = "window.open('" + url + "', 'popup_window', 'width=300,height=100,left=100,top=100,resizable=yes');";
ClientScript.RegisterStartupScript(this.GetType(), "script", s, true);
}
Markup:
<asp:Button Text="Open PopUp" OnClick="OpenPopUp_Click" runat="server" />
Upvotes: 2