HtmlControl.Disabled Property
Gets or sets a value indicating whether the HTML server control is disabled.
[Visual Basic] Public Property Disabled As Boolean [C#] public bool Disabled {get; set;} [C++] public: __property bool get_Disabled(); public: __property void set_Disabled(bool); [JScript] public function get Disabled() : Boolean; public function set Disabled(Boolean);
Property Value
true if the control is disabled; otherwise, false. The default value is false.
Remarks
On the browser, a disabled element or control is read-only, with the following added restrictions: its value is not submitted with the form, the element or control cannot receive focus, and the element or control is skipped when navigating the document by tabbing.
Example
[Visual Basic, C#, JScript] The following example demonstrates how to use the Disabled property to programmatically enable and disable an HtmlInputButton control.
[Visual Basic] <%@ Page Language="VB" AutoEventWireup="True" %> <html> <head> <script language="VB" runat=server> Sub Submit_Clicked(sender As Object, e As EventArgs) Message.InnerHtml = "You clicked the submit button." End Sub 'Submit_Clicked Sub Enable_Clicked(sender As Object, e As EventArgs) Message.InnerHtml = "" Submit2.Disabled = Not Submit2.Disabled End Sub 'Enable_Clicked </script> </head> <body> <form method=post runat=server> <h3>HtmlControl Disabled Property Example</h3> <input id="Submit1" type="submit" value="Enable/Disable Submit Button" OnServerClick="Enable_Clicked" runat="server"/> <br><br> <input id="Submit2" type="submit" value="Submit" OnServerClick="Submit_Clicked" runat="server"/> <br><br> <span id="Message" runat="server"/> </form> </body> </html> [C#] <%@ Page Language="C#" AutoEventWireup="True" %> <html> <head> <script language="C#" runat=server> void Submit_Clicked(Object sender, EventArgs e) { Message.InnerHtml = "You clicked the submit button."; } void Enable_Clicked(Object sender, EventArgs e) { Message.InnerHtml = ""; Submit2.Disabled=!Submit2.Disabled; } </script> </head> <body> <form method=post runat=server> <h3>HtmlControl Disabled Property Example</h3> <input id="Submit1" type="submit" value="Enable/Disable Submit Button" OnServerClick="Enable_Clicked" runat="server"/> <br><br> <input id="Submit2" type="submit" value="Submit" OnServerClick="Submit_Clicked" runat="server"/> <br><br> <span id="Message" runat="server"/> </form> </body> </html> [JScript] <%@ Page Language="JScript" AutoEventWireup="True" %> <html> <head> <script language="jscript" runat=server> function Submit_Clicked(sender: Object, e: EventArgs){ Message.InnerHtml = "You clicked the submit button." } function Enable_Clicked(sender: Object, e: EventArgs){ Message.InnerHtml = "" Submit2.Disabled = !Submit2.Disabled } </script> </head> <body> <form method=post runat=server> <h3>HtmlControl Disabled Property Example</h3> <input id="Submit1" type="submit" value="Enable/Disable Submit Button" OnServerClick="Enable_Clicked" runat="server"/> <br><br> <input id="Submit2" type="submit" value="Submit" OnServerClick="Submit_Clicked" runat="server"/> <br><br> <span id="Message" runat="server"/> </form> </body> </html>
[C++] No example is available for C++. To view a Visual Basic, C#, or JScript example, click the Language Filter button
in the upper-left corner of the page.
Requirements
Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family
See Also
HtmlControl Class | HtmlControl Members | System.Web.UI.HtmlControls Namespace | HtmlInputButton