我想在aspx.cs(c#)中调用JavaScript中的方法hello(),当选择listbox1项目时。使用此代码执行操作但不起作用如何从aspx.cs中调用javascript方法
protected void ListBox1_TextChanged(object sender, EventArgs e)
{
ClientManager.RegisterStartupScript(this, GetType(), "whatiskey","hello();", true);
}
function hello() {
alert("hiiiii");
var arr = ["<%=myvalue %>"];
}
不工作意味着什么?您是否收到任何错误消息 –
没有错误,只是方法没有执行 – phpnet
尝试:Page.ClientScript.RegisterStartupScript(GetType(),“whatiskey”,“hello();”,true); – Zaki