要在源代码中获得ID,在服务器端中用this.xxx.ClientId
string script = string.Format("document.getElementById('{0}').value+='{1}'",
this.TextBox1.ClientID,
DateTime.Now.ToString());
实在要在客户端写,就用绑定,当然这种不能在js文件中引用
<script language="javascript">
document.getElementById('<%=this.TextBox1.ClientID%>').value += "From Client";
</script>
如果又实在要在Js文件中载入,就把它写到function里面去,然后传参数调用
var id='<%=this.TextBox1.ClientID%>';
function Test(id){
document.getElementById(id).value += "From Client";
}
转载于:https://www.cnblogs.com/lishenglyx/archive/2008/08/21/1273110.html