anthem:TextBox 设置 ReadOnly="True" 后 在后台 获取不到文本框中的值 anthem:TextBox 设置 ReadOnly="True" 后 在后台 获取不到文本框中的值 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 附代码。取值与readonly没什么关系 在后台直接设置,TextBox1.Attributes.Add("readonly", "readonly"); <anthem:TextBox ID="txt1" runat="server" Width="19px" ReadOnly="True">aaaaaaaa</anthem:TextBox>在.cs文件中 txt1.Text获取到的就是 "". 弄错了 是这样,页面上有个GridView 上面我放了一个按钮,在GridView1_RowDataBound事件中添加e.Row.Cells[5].Attributes.Add("onclick", "jsFunctionName('" + e.Row.Cells[1].Text.ToString().Trim() + "','" + e.Row.Cells[2].Text.ToString().Trim() + "','" + e.Row.Cells[3].Text.ToString().Trim() + "','" + e.Row.Cells[4].Text.ToString().Trim() + "','" + e.Row.Cells[0].Text.ToString().Trim() + "')");在前端用 <script language="javascript" type="text/javascript"> function jsFunctionName(a,b,c,d,e)//类别 名称 规格 {debugger; var str1=a;var str2=b;var str3=c;var str4=d;var str5=e; window.document.getElementById("txt1").value=str1; if(str2!=" "){ window.document.getElementById("txt2").value=str2;} if(str3!=" "){ window.document.getElementById("txt3").value=str3;} window.document.getElementById("txt4").value=str4; window.document.getElementById("txt5").value=str5; } </script>获取到,这样页面就不会刷新了,txt都是<anthem:TextBox ID="txt1" runat="server" Width="19px"></anthem:TextBox>其中txt1 必须 ReadOnly="True" 但是在点提交后 获取不到txt1的Text值,其他的都可以取到, 通过style设置属性string.isNullOrEmpty(txt1.Text) txt1是什么?不是girdview中的控件吧? 没在girdview中,是独立的文本框 txt1.Attributes["contentEditable"] = "false"; 放在page_load事件里txt1.Attributes["contentEditable"] = "false"; window.document.getElementById("txt1").value=str1;==>>window.document.getElementById("txt1").innerHTML=str1;看看会怎样?我不用ASP控件,对ASP控件不熟悉 你是不是在page_load事件里面写了文本框等于空啊?可能页面回传的时候给他赋了空值。 通过style设置属性 设置只读,怎么可能读不到值呢。string.isNullOrEmpty(txt1.Text) 是否为空 不要设置 TextBox 的 ReadOnly="True" 因为 它在获取值的时候 会判断 ReadOnly 属性,如果为 true 是不会获取新值的使用 TextBoxID.Attributes.Add("readonly","true"); txt1.Attributes["contentEditable"] = "false"; 很正确的说 C#调用C++的dll的类型问题 利用配置实现增删改查 利用XML配置实现CRUD 请问在前台如何response.write("<%# Eval("id")%>")这样的语句? 大家看看,没有什么办法可以知道用户在改变FCKEDITOR的值,在线等,马上结贴,给分,大家帮帮忙阿 关于用户权限设置问题! asp.net 怎么样负值传递参数??? 字符串与时间的比较问题 datagrid的超链接列的取值问题 请高手出面! gridview 通过存储过程更新没有反应 淘宝开放API里怎么取sessionKey啊 有谁知道啊 急啊
txt1.Text获取到的就是 "".
在前端用 <script language="javascript" type="text/javascript"> function jsFunctionName(a,b,c,d,e)//类别 名称 规格
{debugger;
var str1=a;var str2=b;var str3=c;var str4=d;var str5=e;
window.document.getElementById("txt1").value=str1;
if(str2!=" "){
window.document.getElementById("txt2").value=str2;}
if(str3!=" "){
window.document.getElementById("txt3").value=str3;}
window.document.getElementById("txt4").value=str4;
window.document.getElementById("txt5").value=str5;
}
</script>
获取到,这样页面就不会刷新了,txt都是
<anthem:TextBox ID="txt1" runat="server" Width="19px"></anthem:TextBox>
其中txt1 必须 ReadOnly="True"
但是在点提交后 获取不到txt1的Text值,其他的都可以取到,
string.isNullOrEmpty(txt1.Text)
txt1.Attributes["contentEditable"] = "false";
看看会怎样?
我不用ASP控件,对ASP控件不熟悉
string.isNullOrEmpty(txt1.Text) 是否为空