Tajkumar
Tajkumar

Reputation: 337

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

Upvotes: 0

Views: 2417

Answers (2)

Kaptan
Kaptan

Reputation: 336

string url = "~/Printticket.aspx";

Your url path plus your form name like ~/SomeFolder//Printticket.aspx

Upvotes: 0

Jay Douglass
Jay Douglass

Reputation: 4918

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.

Upvotes: 1

Related Questions