ASP.Net TextBox只读时不能取值的解决方案
来源:互联网 发布:asp 导出数据到excel 编辑:程序博客网 时间:2024/05/29 18:41
给页面的TextBox设置ReadOnly="True"时,在后台代码中不能赋值取值,下边几种方法可以避免:
1、不设置ReadOnly,设置onfocus=this.blur()
C#代码
<asp:TextBox ID="TextBox1" runat="server" onfocus=this.blur()></asp:TextBox>
<asp:TextBox ID="TextBox1" runat="server" onfocus=this.blur()></asp:TextBox>
文本框不变灰色,但也无法手动修改内容,可以在后台通过Text属性正常赋值取值
2、设置了ReadOnly属性后,通过Request来取值,如下:
前台代码:
<asp:TextBox ID="TextBox1" runat="server" ReadOnly="True" ></asp:TextBox>
<asp:TextBox ID="TextBox1" runat="server" ReadOnly="True" ></asp:TextBox>
后台代码:
string Text = Request.Form["TextBox1"].Trim();
string Text = Request.Form["TextBox1"].Trim();
3、在Page_Load()正设置文本框的只读属性,能正常读取,如下:
C#代码
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
TextBox1.Attributes.Add("readonly","true");
}
}
- ASP.Net TextBox只读时不能取值的解决方案
- ASP.Net TextBox只读时不能取值的解决方案
- ASP.Net TextBox只读时不能取值
- ASP.NET中TextBox设置只读时不能取值的处理
- asp.net TextBox只读时不能通过后台赋值取值解决办法
- asp.net TextBox只读时不能通过后台赋值取值解决办法
- ASP.Net TextBox只读时不能通过后台赋值取值
- ASP.Net TextBox只读时不能通过后台赋值取值
- ASP.Net TextBox只读时不能通过后台赋值取值
- ASP.Net TextBox 只读(ReadOnly)时后台不能赋值取值
- ASP.Net TextBox只读时不能通过后台赋值取值
- ASP.Net TextBox只读时不能通过后台赋值取值
- asp.net 中TextBox只读时在客户端赋值后的取值问题
- asp.net中TextBox设为只读后的取值问题
- asp.net TextBox 设置为只读后 后台取不到JS设置的值
- asp.net中TextBox设为只读后的取值问题
- TextBox只读时不能通过后台赋值取值解决办法
- asp.net textbox只读时不能通过javascript赋值、采值解决办法
- 使用ASM存储EXPDP转储文件
- vs2010 头文件注意事项
- 郑州大学第八届校赛正式赛题解
- Java读取注册表的三种方法
- 使用Eclipse构建Maven的SpringMVC项目
- ASP.Net TextBox只读时不能取值的解决方案
- ubuntu常用设置
- Android sdcard读写文件(二)
- Kinect API 简述
- GNU Linux 64位系统中fatal error: stdio.h: 没有那个文件或目录的错误的解决方法
- 错误信息could not resolve property: xxx of: pojo.xxxx
- StackOverflow程序员推荐:每个程序员都应读的30本书
- iOS_基于百度地图的开发
- Codefoeces 3A. Shortest path of the king