[CLOSED] [component].Disabled = false is not the same as [component].Enabled = true

  1. #1

    [CLOSED] [component].Disabled = false is not the same as [component].Enabled = true

    Hi,
    we have found a strange effect:

    public partial class WebForm2 : System.Web.UI.Page
    {
        ToolbarButton mapButton = new ToolbarButton();
    
        protected void Page_Load(object sender, EventArgs e)
        {
            ...
            CreateToolbar(update)
            ...
        }
    
        void CreateToolbar(bool update)
        {
            Toolbar tb = new Toolbar();
            ...
            mapButton = new ToolbarButton();
            mapButton.Icon = Icon.FolderAdd;
            mapButton.AjaxEvents.Click.Before = "parent.window.StatusBar.showBusy();";
            mapButton.Text = "...";
            mapButton.AjaxEvents.Click.Event += new ComponentAjaxEvent.AjaxEventHandler(this.AddToMap);
            mapButton.AjaxEvents.Click.ExtraParams.Add(new Coolite.Ext.Web.Parameter("NodeID", "parent.window.CurrentNodeID.getValue()", ParameterMode.Raw));
            mapButton.AjaxEvents.Click.EventMask.ShowMask = true;
            mapButton.AjaxEvents.Click.EventMask.Msg = "...";
            mapButton.AjaxEvents.Click.EventMask.MinDelay = 200;
            mapButton.ID = "MapButton";
            mapButton.Hidden = !update;
            tb.Items.Add(mapButton);
            ...
    
        }
    
        protected void AddToMap(object sender, AjaxEventArgs e)
        {
            mapButton.Disabled = true;
            try
            {
                ...
            }
            ...
            finally
            {
                // mapButton.Enabled = true;
                mapButton.Disabled = false;
            }
        }
        ...
    }
    The effect:
    If we use 'mapButton.Disabled = false;' instead of 'mapButton.Enabled = true;'
    and click the mapButton twice we receive a
    System.Web.HttpException: The control with ID 'MapButton' not found

    Please take a look into Coolite.Ext.Web\Ext\Component.cs
    If I change
            public virtual bool Disabled
            {
                get
                {
                    object obj = this.ViewState["Disabled"];
                    return (obj == null) ? false : (bool)obj;
                }
                set
                {
                    this.ViewState["Disabled"] = value;
                }
            }
    
            public override bool Enabled
            {
                get
                {
                    return base.Enabled;
                }
                set
                {
                    this.Disabled = !value;
                    base.Enabled = value;
                }
            }
    into

            public virtual bool Disabled
            {
                get
                {
                    object obj = this.ViewState["Disabled"];
                    return (obj == null) ? false : (bool)obj;
                }
                set
                {
                    this.ViewState["Disabled"] = value;
                    base.Enabled = !value;
    
                }
            }
    
            public override bool Enabled
            {
                get
                {
                    return base.Enabled;
                }
                set
                {
                    this.Disabled = !value;
                }
            }
    the problem is resolved.

    What is or should be the difference between the properties 'Enabled' and 'Disabled' ?

    Regards,
    M. Blume
  2. #2

    RE: [CLOSED] [component].Disabled = false is not the same as [component].Enabled = true

    Hi,

    I can't reproduce the error. A single suggestion that you don't recreate this button on some request (may be?). Can you show simple sample which reproduces the error


    P.S. In your AddToMap ajax event handler you set Disabled=true and in finally block Disabled=false. I don't recomend use it because each Disabled setting generates javascript code (to the client will send*MapButton.setDisabled(true);MapButton.setDisabled( false);)


Similar Threads

  1. Replies: 4
    Last Post: Jun 30, 2011, 6:25 PM
  2. [CLOSED] Radio component inside window hidden=true
    By jeybonnet in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Dec 10, 2010, 8:52 PM
  3. [CLOSED] [1.0] - Toolbar Button looks enabled when Disabled = true
    By drkoh in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Jul 01, 2010, 5:36 PM
  4. Add Ext JavaScript Component to Component
    By geoffrey.mcgill in forum Examples and Extras
    Replies: 3
    Last Post: Mar 10, 2010, 12:38 PM
  5. [CLOSED] Disabled Checkbox is always false and shows enabled true.
    By Sharon in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Nov 12, 2009, 4:10 AM

Posting Permissions