读书人

在JavaScript中怎么对TextBox的值进

发布时间: 2012-04-27 11:57:44 作者: rapoo

在JavaScript中,如何对TextBox的值进行修改?
if (confirm("你确认要删除记录吗?")) {
//var txtBox1 = document.getElementById("TextBox_Del");
//txtBox1.value = "yes";

//document.form1.TextBox_Del.value = "yes";
document.all["TextBox_Del"].value = "yes";
}
else {
//var txtBox1 = document.getElementById("TextBox_Del");
//txtBox1.value = "no";
//document.form1.TextBox_Del.value = "no";
document.all["TextBox_Del"].value = "no";
}
TextBox_Del的AutoPostBack="True",上面的三种方法,我都试了,都不成功。我在aspx.cs文件中,用:
string MessageBox = TextBox_Del.Text;取出来的值总是空字符串。这是为什么?

[解决办法]
var obj = document.getElementById("<%=TextBox_Del.ClientID %>");
if(confirm("delete?")){
obj.value = "yes";
}else{
obj.value = "no";
}

[解决办法]

HTML code
<html xmlns="http://www.w3.org/1999/xhtml" ><head runat="server">    <title>Untitled Page</title>    <script type="text/javascript">        function textchange(){            var obj = document.getElementById("<%=TextBox_Del.ClientID %>");             if(confirm("delete?")){                 obj.value = "yes";             }else{                 obj.value = "no";             }         }    </script></head><body>    <form id="form1" runat="server">    <div>    <asp:Literal ID="li_showValue" runat="server" /><br />    <asp:TextBox ID="TextBox_Del" onchange="textchange();" runat="server" AutoPostBack="true" />    </div>    </form></body></html>
[解决办法]
我是这么写的 可以的
前台:
JScript code
 function clicked() {    document.getElementById('TextBox3').value="Hello Word!"; } 

读书人网 >asp.net

热点推荐