我是 js 的新手,在尝试从我的代码隐藏中调用 js 函数时遇到了问题。
C#:
protected void GridView3_OnSelectedIndexChanged(object sender, EventArgs e)
{
tbListOfCountries.Text = GridView3.SelectedRow.Cells[1].Text;
Page.ClientScript.RegisterStartupScript(this.GetType(), "test", "test()", true);
}
JavaScript:
function test() {
alert("test");
}
意外标识符错误:
//<![CDATA[
test()Sys.Application.add_init(function() {
$create(Sys.Extended.UI.TabPanel, {"headerTab":$get("__tab_TabContainer1_TabPanel1"),"ownerID":"TabContainer1","wasLoadedOnce":true}, null, {"owner":"TabContainer1"}, $get("TabContainer1_TabPanel1"));
});
有什么见解吗?
最佳答案
看起来您的脚本 test()
在语法上不正确。尝试替换为 test();
关于javascript - 使用 registerstartupscript 时出现意外标识符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46223314/