简体   繁体   中英

Open a new window from codebehind C# with window.open

i want to open a new window i have tried window.open

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);

when i tried this from the samefolder which the print ticket is theior iam getting it right but when i tried it from the different folder iam not getting popup

You need to use the site relative url:

string url = ResolveUrl("~/yourfolder/Printticket.aspx");

I would always try to use site relative urls in asp.net so that urls work across your app, no matter what folder your pages are in.

string url = "~/Printticket.aspx";

您的网址路径以及您的表单名称,例如〜/ SomeFolder // Printticket.aspx

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM