gpt4 book ai didi

javascript - 使用 registerstartupscript 时出现意外标识符

转载 作者:太空宇宙 更新时间:2023-11-03 22:54:12 25 4
gpt4 key购买 nike

我是 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com