asp.net TextBox控件设置ReadOnly后,不能回传。
摘要:很奇怪,以前都没有过这样的怪问题,在别人机器上都能正常,想到可能和ASP.NET的版本有关系。我用的是ASP.NET2.0,当改成ASP.N...
很奇怪,以前都没有过这样的怪问题,在别人机器上都能正常,想到可能和ASP.NET的版本有关系。
我用的是 ASP.NET 2.0,当改成 ASP.NET 1.0,就正常了,TextBox控件ReadOnly=True,能回传。
在 ASP.NET 1.0 中是ReadOnly=True会回传的。
在 ASP.NET 2.0 中是ReadOnly=True就不会回传了。
解决的方法:
<asp:textbox id="Username" runat="server" ReadOnly="True"></asp:textbox>
去掉ReadOnly="True",改成
<asp:textbox id="Username" runat="server"></asp:textbox>
在后台代码中加入,控制只读属性
Username.Attributes.Add("Readonly", "True");
这样在 ASP.NET 2.0 中只读的TextBox控件也能实现回传。
【asp.net TextBox控件设置ReadOnly后,不能回传。】相关文章:
★ asp.net neatUpload 支持大文件上传组件
★ asp.net request.PathInfo实现的url重写
上一篇:
asp.net 下载文件时输出文件内容
下一篇:
c# 执行事务函数代码