Get value of disabled control

  1. #1

    Get value of disabled control

    Hi,

    When I try to get a value of a disabled control (combobox, datefield,...) it's empty, but the fields have content. Is it a bug?


    Thanks.
  2. #2

    RE: Get value of disabled control

    I've also noted this. Would be nice to have fixed.

    Cheers,
    Timothy
  3. #3

    RE: Get value of disabled control

    Hi,

    Can you post a sample which reproduces the error, or modify the code sample below.

    Example

    <%@ Page Language="C#" %>
    
    <%@ Register assembly="Coolite.Ext.Web" namespace="Coolite.Ext.Web" tagprefix="ext" %>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!this.Page.IsPostBack || !Ext.IsAjaxRequest)
            {
                this.TextField1.Text = "Hello";
                this.TextBox1.Text = "World";
            }
        }
        
        protected void Button1_Click(object sender, EventArgs e)
        {
            string tmp = "TextField1: {0}<br />TextBox1: {1}<br />{2}";
    
            this.Label1.Html = string.Format(tmp, this.TextField1.Text, this.TextBox1.Text, DateTime.Now.ToLongTimeString());
        }
    </script>
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head id="Head1" runat="server">
        <title>Coolite Toolkit Example</title>
    </head>
    <body>
        <form runat="server">
            <ext:ScriptManager ID="ScriptManager1" runat="server" />
        
            <ext:TextField ID="TextField1" runat="server" Enabled="false" />
            
            <asp:TextBox ID="TextBox1" runat="server" Enabled="false" />
            
            <ext:Button ID="Button1" runat="server" Text="Submit">
                <AjaxEvents>
                    <Click OnEvent="Button1_Click" />
                </AjaxEvents>
            </ext:Button>
            
            <ext:Label ID="Label1" runat="server" />
        </form>
    </body>
    </html>
    Geoffrey McGill
    Founder
  4. #4

    RE: Get value of disabled control

    Use a regular post back with AutoPostBack="True" should do it Geoffrey.

    Cheers,
    Timothy
  5. #5

    RE: Get value of disabled control

    I'll retest with AutoPostback="true", although I would expect the same results because a standard PostBack and an AjaxEvent both use exactly the same internals. An AjaxEvent is a PostBack, but only performed asynchronously. But... I will test the scenario to confirm.

    Geoffrey McGill
    Founder
  6. #6

    RE: Get value of disabled control

    Here's what I'm testing with now.

    Example

    <%@ Page Language="C#" %>
    
    <%@ Register assembly="Coolite.Ext.Web" namespace="Coolite.Ext.Web" tagprefix="ext" %>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!this.Page.IsPostBack)
            {
                this.TextField1.Text = "Hello";
                this.TextBox1.Text = "World";
            }
        }
        
        protected void Button1_Click(object sender, EventArgs e)
        {
            string tmp = "TextField1: {0}<br />TextBox1: {1}<br />{2}";
    
            this.Label1.Html = string.Format(tmp, this.TextField1.Text, this.TextBox1.Text, DateTime.Now.ToLongTimeString());
        }
    </script>
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head id="Head1" runat="server">
        <title>Coolite Toolkit Example</title>
    </head>
    <body>
        <form runat="server">
            <ext:ScriptManager ID="ScriptManager1" runat="server" />
        
            <ext:TextField ID="TextField1" runat="server" Enabled="false" />
            
            <asp:TextBox ID="TextBox1" runat="server" Enabled="false" />
            
            <ext:Button ID="Button1" runat="server" Text="Submit" AutoPostBack="true" &#111;nclick="Button1_Click" />
            
            <ext:Label ID="Label1" runat="server" />
        </form>
    </body>
    </html>
    Hope this helps.

    Geoffrey McGill
    Founder
  7. #7

    RE: Get value of disabled control

    <P class=MsoNormal style="MARGIN: 0cm 0cm 4.5pt"> Hi,

    For example, I have this combobox:



    
    <P class=MsoNormal style="MARGIN: 0cm 0cm 4.5pt"><ext:ComboBox ID="cbChannel" AllowBlank="false" BlankText="<%$Resources: itemObligatory %>" runat="server" StoreID="storeChannelsTypes" Width="120" DisplayField="Description" ValueField="UniqueId" TypeAhead="true" Mode="Local" TriggerAction="All" Editable="false" ItemSelector="div.list-item" SelectOnFocus="true" EmptyText="<%$ Resources: cbEmptyText %>">
        <Template ID="Template4" runat="server">
            <tpl for=".">
                <div class="list-item">
                    <h3>{Description}</h3>
                
    
            </tpl>
        </Template>
    </ext:ComboBox>

    If I do the next operations:

     
    <P class=MsoNormal style="MARGIN: 0cm 0cm 4.5pt">    this.cbChannel.Disable();
        string sValue = this.cbChannel.SelectedItem.Value;
    sValue always is empty, even if I have selected any item of the combobox.
    Then... if I disable the combo I can't get its value.

    I hope that this example can be useful to you.


    Thank you for your time.


  8. #8

    RE: Get value of disabled control

    With the textfield itsn't happend. It happends, almost, with the combobox control and datafield control.
  9. #9

    RE: Get value of disabled control

    I modify it. I also had problems with the textfield when it was disabled.


    Best wishes.

Similar Threads

  1. TextField disabled bug ?
    By xtremexploit in forum 1.x Help
    Replies: 5
    Last Post: Nov 14, 2011, 4:41 PM
  2. Check if control is enabled or disabled
    By AlexMaslakov in forum 1.x Help
    Replies: 1
    Last Post: Oct 12, 2011, 11:19 AM
  3. Disabled Icons
    By GijsZePa in forum Bugs
    Replies: 2
    Last Post: Jun 25, 2010, 8:33 AM
  4. Replies: 1
    Last Post: Mar 09, 2010, 2:55 AM
  5. Disabled tabs
    By dbassett74 in forum 1.x Help
    Replies: 1
    Last Post: Jun 02, 2009, 1:22 PM

Posting Permissions