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?
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.