比如我从Toolbox中的Standard页面拖一个编辑框出来,在Default.aspx的源码中多出<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>。我现在试图在Default.aspx源码中用script改变编辑框里的文字,怎么做?我这样写没有效果
function Button1_onclick() {
document.getElementById("TextBox1").setAttribute("Text", "abcd");
}
在线等!
function Button1_onclick() {
document.getElementById("TextBox1").setAttribute("Text", "abcd");
}
在线等!
如果你的textbox没有放在一个容器控件中,则其生成的html中的id为TextBox1
可以用如下语句:
document.getElementById('TextBox1').value = 'abcd';