WebControl.IsEnabled 屬性
定義
取得值,指出是否啟用控制項。Gets a value indicating whether the control is enabled.
protected public:
property bool IsEnabled { bool get(); };
protected internal bool IsEnabled { get; }
member this.IsEnabled : bool
Protected Friend ReadOnly Property IsEnabled As Boolean
屬性值
如果啟用 WebControl 物件,則為 true
,否則為 false
。true
if the WebControl object is enabled; otherwise, false
.
備註
這是一個唯讀屬性。This is a read-only property. 如果您想要停用控制項,請將其 Enabled 屬性設定為 false
。If you want to disable a control, you set its Enabled property to false
.
如果控制項不包含在另一個控制項中,屬性的值 IsEnabled 永遠會與屬性的值相同 Enabled 。If a control is not contained by another control, the value of the IsEnabled property is always the same as the value of the Enabled property.
IsEnabled Enabled 如果控制項是另一個控制項的子系,而且下列所有情況都成立,則屬性的值會與屬性不同:The IsEnabled property has a value that is different from the Enabled property if a control is a child of another control and if all the following circumstances are true:
Enabled父控制項的屬性值或 IsEnabled 屬性值為
false
。The value of the Enabled property or the IsEnabled property of the parent control isfalse
.Enabled子控制項的屬性設定為
true
。The Enabled property of the child control is set totrue
.
在這種情況下,子控制項會繼承父控制項的停用狀態。In this situation, the child control inherits the disabled state of the parent control. IsEnabled子控制項的屬性會傳回, false
表示即使子控制項的屬性設定為,也會停用該控制項,即使子控制項未明確停用也一樣 Enabled false
。The IsEnabled property of the child control returns false
to indicate that the control is disabled even though the child control was not explicitly disabled by setting its Enabled property to false
. 父控制項本身可能會將其 Enabled 屬性設定為 true
,但可能會從其父系繼承停用的狀態,依此類推。The parent control itself might have its Enabled property set to true
but might inherit the disabled state from its parent, and so on.
當 ASP.NET 轉譯伺服器控制項的 HTML 元素時,它會藉由設定 disabled
屬性或其 CSS 屬性將專案標示為已停用 class
。When ASP.NET renders HTML elements for a server control, it marks the elements as disabled by setting their disabled
attribute or their CSS class
attribute. 如需詳細資訊,請參閱 SupportsDisabledAttribute 和 ControlRenderingCompatibilityVersion。For more information, see SupportsDisabledAttribute and ControlRenderingCompatibilityVersion.