开发者

problem using page.registerstartupscript

I am using page.registerstartupscr开发者_如何学Goipt in my code behind C#. Its like this:

string item1="category1"; string Script = "window.program = '" + item1 + "';"; Page.RegisterStartupScript("PopupScript", Script);

item1 gets generated dynamically from some value in code behind. But its not working. Any suggestoins where I m getting wrong?


You need it wrapped in script tags, there's an overload for this in the newer replacement ClientScript:

string item1="category1";
string Script = "window.program = '" + item1 + "';";
Page.ClientScript.RegisterStartupScript(GetType(), "PopupScript", Script, true);

Unless you're on .Net 1.1 I believe, Page.RegisterStartupScript is deprecated.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜