Recommended way to enable/disable controls from server side?

  1. #1

    Recommended way to enable/disable controls from server side?

    Hi there,

    Again, apologies for the (hopefully) simplistic nature of this query! but I was wondering what the recommended method of disabling a control (in this case a combobox but it could be anything) from the server side?

    I'm aware that client side we can just called combobox.enable()/combobox.disable() but what are the server side equivilents?

    I can happily disable the control using:
    combobox.Disabled = true;

    but when trying to use either:

    - combobox.Disabled = false;
    or
    - combobox.Enabled = true;

    the control does not seem to activate again.

    Am I missing something here?

    Cheers,

    Doug
  2. #2
    Hi Doug,

    I'm not too sure, but setting .Disabled = true|false appears to work correctly in my tests.

    Example

    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <script runat="server">
        protected void Button1_Click(object sender, DirectEventArgs e)
        {
            this.ComboBox1.Disabled = true;
        }
    
        protected void Button2_Click(object sender, DirectEventArgs e)
        {
            this.ComboBox1.Disabled = false;
        }
    </script>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>Ext.NET Example</title>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
    
            <ext:ComboBox ID="ComboBox1" runat="server">
                <Items>
                    <ext:ListItem Text="Item1" />
                    <ext:ListItem Text="Item2" />
                    <ext:ListItem Text="Item3" />
                </Items>
            </ext:ComboBox>
    
            <ext:Button runat="server" Text="Disable" OnDirectClick="Button1_Click" />
            <ext:Button runat="server" Text="Enable" OnDirectClick="Button2_Click" />
        </form>
    </body>
    </html>
    Hope this helps.
    Geoffrey McGill
    Founder
  3. #3
    *Grumble* *Grumble*

    I have must have been seeing some odd browser weirdness or possible caching? As this morning .Disabled = true seems perfectly happy!

    Thanks for confirming I wasn't going mad!

    Cheers,

    Doug

Similar Threads

  1. [CLOSED] How to enable/disable paging on the client or server?
    By vadym.f in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Jul 10, 2012, 2:37 PM
  2. [CLOSED] Enable/disable DirectEvent confirmation on server side
    By jmcantrell in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: May 29, 2012, 4:53 PM
  3. [CLOSED] Server side controls values with DirectEvent calls
    By Daniil in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Feb 10, 2012, 11:52 AM
  4. Button Enable/Disable
    By Maia in forum 1.x Help
    Replies: 5
    Last Post: Jul 02, 2010, 8:03 PM
  5. [CLOSED] How to disable/enable all controls in formpanel
    By idrissb in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Oct 13, 2009, 12:21 PM

Tags for this Thread

Posting Permissions