C# 将值从代码隐藏传递到JavaScript函数
下面是我的JavaScript函数C# 将值从代码隐藏传递到JavaScript函数,c#,javascript,asp.net,C#,Javascript,Asp.net,下面是我的JavaScript函数 function HighlightWord(highlightword) { alert(highlightword); } 当我使用下面的代码将值传递给上面的函数时 Page.ClientScript.RegisterStartupScript(this.GetType(), "onload", "HighlightWord(abc)", true); 警报显示“未定义”。这有什么不对?谢谢 Page.ClientScript.Regis
function HighlightWord(highlightword) {
alert(highlightword);
}
当我使用下面的代码将值传递给上面的函数时
Page.ClientScript.RegisterStartupScript(this.GetType(), "onload", "HighlightWord(abc)", true);
警报显示“未定义”。这有什么不对?谢谢
Page.ClientScript.RegisterStartupScript(this.GetType(), "onload", "HighlightWord(abc)", true);
表示提醒我假定您没有的abc
变量。应该是
Page.ClientScript.RegisterStartupScript(this.GetType(), "onload", "HighlightWord('abc')", true);`.
这将提醒“abc”,这是我认为您希望发生的事情