Reputation: 337
I am using gridview
to display the booking history when the user clicks on a "print" button. A printticket.aspx
page should open in a new window.
I have used window.open
but it is blocked by the browser.
string url = "../Printticket.aspx";
string fullURL = "window.open('" + url + "', '_blank', 'height=600,width=1000,status=yes,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes,titlebar=no' );";
ScriptManager.RegisterStartupScript(this, typeof(string), "OPEN_WINDOW", fullURL, true);
I want to open the printticket
page in a new window. Is there any other way?
Upvotes: 1
Views: 14784
Reputation: 1530
I had the same problem and have managed to resolve it.
This solutions works for both ASP:Button
and ASP:LinkButton
.
string url = "../Printticket.aspx";
string fullURL = "window.open('" + url + "', '_blank', 'height=600,width=1000,status=yes,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes,titlebar=no' );";
btnButton.OnClientClick = fullURL;
Where btnButton
is typeof(Button)
or typeof(LinkButton)
Hope this helps someone later.
Upvotes: 1