我使用下面的代码来查找控件id。
alert(document.getElementById("<%# TextBox1.ClientId %>").value )但是这段代码给出了错误"object required“。请帮帮我。
发布于 2012-05-16 20:20:33
要么使用
alert(document.getElementById("<%= TextBox1.ClientId %>").value )或者为textbox设置ClientIDMode="Static",然后
alert(document.getElementById("<%= TextBox1 %>").value )另请检查How to: Access Controls from JavaScript by ID
发布于 2012-05-16 20:14:26
您需要使用'=',而不是'#‘
alert(document.getElementById("<%= TextBox1.ClientId %>").value );"<%#“符号是用于数据绑定的内联表达式。
这里的"<%=“符号用于显示/翻译。它基本上只执行服务器控件的.ClientID属性值的Response.Write。
有关详细信息,请参阅this article on inline expressions in asp.net。
发布于 2012-05-16 20:14:43
replace # with =在给定语句中更新语句为
alert(document.getElementById("<%= TextBox1.ClientId %>").value);https://stackoverflow.com/questions/10618196
复制相似问题