只读有关客户详细信息的文本框

Read only text boxes on customer details

我试图在一个网站上显示客户详细信息,该网站对一种客户类型只读但对另一种客户类型可用。如何添加此功能?

所以有一个TextBox.ReadOnly property which you can set for the aspx controls. For the input you would just need to put readonly作为属性

例如:

  <input readonly name="txtName" type="text" id="txtName" runat="server" onchange="ProfileIsDirty()" ToolTip="Name" class="form-control height-fix no-border-bottom"  placeholder="NAME" MaxLength="200"/>
<form action="demo_form.asp">
  Country: <input type="text" name="country" value="Norway" disabled><br>
  <input type="submit" value="Submit">
</form>

"disabled" 属性阻止用户交互

根据用户,您可以将 readonly 属性添加到文本框。

假设您希望文本框对特定用户是只读的,那么,

txtName.Attributes.Add("readonly","readonly");

对于其他用户,不要添加此行。

此外,readonly 将阻止用户编辑数据,尽管光标位于该字段中。因此无需担心编辑。