的ReadOnly
屬性設置爲true 包括the attribute being set:
if (ReadOnly) {
writer.AddAttribute(HtmlTextWriterAttribute.ReadOnly, "readonly");
}
然而,屬性也會影響到回發的行爲。它只會保存在視圖狀態的文本時,它的not readonly(原代碼縮短):
private bool SaveTextViewState {
get {
if (TextMode == TextBoxMode.Password) {
return false;
}
if (Events[EventTextChanged] != null || !IsEnabled || !Visible || (ReadOnly) || this.GetType() != typeof(TextBox)) {
return true;
}
return false;
}
}
而且控制也只嘗試to restore it時是這樣的話:
protected virtual bool LoadPostData(string postDataKey, NameValueCollection postCollection) {
// …
if (!ReadOnly && !current.Equals(postData, StringComparison.Ordinal)) {
Text = postData;
return true;
}
return false;
}