asp:TextBox ReadOnly=true 或 Enabled=false?

发布于 2024-07-06 13:17:42 字数 54 浏览 13 评论 0原文

asp:TextBox 控件的 Enabled 属性和 ReadOnly 属性之间有什么区别?

What's the difference between the Enabled and the ReadOnly-properties of an asp:TextBox control?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

一城柳絮吹成雪 2024-07-13 13:17:42

如果控件被禁用,则无法对其进行编辑并且在提交表单时其内容将被排除。

如果控件是只读,则无法对其进行编辑,但其内容(如果有)仍包含在提交中。

If a control is disabled it cannot be edited and its content is excluded when the form is submitted.

If a control is readonly it cannot be edited, but its content (if any) is still included with the submission.

方觉久 2024-07-13 13:17:42

另一种行为是,readonly = 'true' 控件将触发 click 等事件,但 Enabled = False 控件则不会。

Another behaviour is that readonly = 'true' controls will fire events like click, buton Enabled = False controls will not.

ぇ气 2024-07-13 13:17:42

Readonly 不会使文本框“灰显”,并且仍会在回发时提交值。

Readonly will not "grayout" the textbox and will still submit the value on a postback.

此刻的回忆 2024-07-13 13:17:42

从浏览器的角度考虑一下。 对于只读,浏览器将发送变量/值对。 对于残疾人来说,不会。

运行它,然后在点击提交后查看 URL:

<html>
<form action=foo.html method=get>
<input name=dis type=text disabled value="dis">
<input name=read type=text readonly value="read">
<input name=normal type=text value="normal">
<input type=submit>
</form>
</html>

Think about it from the browser's point of view. For readonly the browser will send in a variable/value pair. For disabled, it won't.

Run this, then look at the URL after you hit submit:

<html>
<form action=foo.html method=get>
<input name=dis type=text disabled value="dis">
<input name=read type=text readonly value="read">
<input name=normal type=text value="normal">
<input type=submit>
</form>
</html>
独﹏钓一江月 2024-07-13 13:17:42

只读将允许用户从中复制文本。 残疾人不会。

Readonly will allow the user to copy text from it. Disabled will not.

五里雾 2024-07-13 13:17:42

Asp.net 中的只读文本框

<asp:TextBox ID="t" runat="server" Style="margin-left: 20px; margin-top: 24px;"
Width="335px" Height="41px" ReadOnly="true"></asp:TextBox>

Readonly textbox in Asp.net

<asp:TextBox ID="t" runat="server" Style="margin-left: 20px; margin-top: 24px;"
Width="335px" Height="41px" ReadOnly="true"></asp:TextBox>
冷默言语 2024-07-13 13:17:42

我有一个子 aspx 表单,它在服务器端执行地址查找。 然后,子 aspx 页面中的值通过 javascript 客户端传递回父文本框。

尽管您可以看到文本框已更改,但只读或启用都不允许将值回发到父表单中。

I have a child aspx form that does an address lookup server side. The values from the child aspx page are then passed back to the parent textboxes via javascript client side.

Although you can see the textboxes have been changed neither ReadOnly or Enabled would allow the values to be posted back in the parent form.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文