ASP:文本框只读 [英] asp:textbox readonly

查看:130
本文介绍了ASP:文本框只读的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在ASP文件中,我有两个ASP:文本框

In asp file I have two asp:textbox

<asp:TextBox ID="textValue" runat="server" Width="100px"/>
<asp:TextBox ID="textValue2" runat="server" Width="100px" ReadOnly="true"/>

然后我通过JavaScript设置的值获得

then I set the value via javascript getting

<asp:TextBox ID="textValue" runat="server" Width="100px" value="aaa"/>
<asp:TextBox ID="textValue2" runat="server" Width="100px" ReadOnly="true" value="bbb"/>

但刷新网页时终于得到

but when refresh the webpage finally get

<asp:TextBox ID="textValue" runat="server" Width="100px" value="aaa"/>
<asp:TextBox ID="textValue2" runat="server" Width="100px" ReadOnly="true"/>

为什么值BBB丢失?我怎样才能避免这种情况?

Why the value bbb is "lost"? How can I avoid this?

推荐答案

BBB被贴后背,但.NET不会从填充回发数据的只读文本框。您可以自己从的Page_Load()方法抓住了表单数据手动填充文本框如下:

"bbb" is being posted back, but .NET will not populate a read-only textbox from postback data. You can manually populate the text box by grabbing the form data yourself from the Page_Load() method as follows:

textValue2.Text =的Request.Form [textValue2.UniqueID];

这篇关于ASP:文本框只读的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆