kevin
kevin

Reputation: 14095

javascript issue in C#

I write this coding in C# in my sharepoint project. It works well.

ClientScript.RegisterStartupScript(this.GetType(), "ale", "window.open('DownloadHandler.ashx?fileName=Error.log');", true);

But when I change my coding to this, it no longer works.

ClientScript.RegisterStartupScript(this.GetType(), "ale", string.Format("window.open('DownloadHandler.ashx?fileName={0}')", "Error.log"), true);

What's wrong with my coding?

Upvotes: 0

Views: 182

Answers (2)

Tomislav Markovski
Tomislav Markovski

Reputation: 12366

So it's missing a semi colon ; at the end.

ClientScript.RegisterStartupScript(this.GetType(), "ale", string.Format("window.open('DownloadHandler.ashx?fileName={0}');", "Error.log"), true);

Upvotes: 1

Jared Farrish
Jared Farrish

Reputation: 49238

There's a missing ; at the end of the window.open() statement:

ClientScript.RegisterStartupScript(
    this.GetType(), 
    "ale", 
    string.Format("window.open('DownloadHandler.ashx?fileName={0}');", "Error.log"),
    true
);

Upvotes: 2

Related Questions