FieldSet's property Collapsed seems not work well

  1. #1

    FieldSet's property Collapsed seems not work well

    Hi:
    Here is my codes:

    Exaple:
                <ext:FieldSet id="fs" Title="FieldSet1" Collapsible="true" runat="server">
                </ext:FieldSet>
    
                <ext:Button ID="btn" Text="button1" runat="server">
                    <DirectEvents>
                        <Click OnEvent="btn_Click"></Click>
                    </DirectEvents>
                </ext:Button>
    Code Behind:
        protected void Page_Load(object sender, EventArgs e)
        {
            fs.Collapsed = true; // let the fieldset collapsed in codebehind
        }
    
        protected void btn_Click(object sender, DirectEventArgs e)
        {
            X.MessageBox.Alert("is collapsed?", fs.Collapsed.ToString()).Show(); // show the fieldset's status
        }
    Do as follow:
    Let the fieldset collapsed in codebehind, and then expand it in IE, click the button to check the result.
    The alert shows 'True'!
    When the page postback, the fieldset has been expanded, why the Collapsed=true?:p
  2. #2
    Hi,

    When DirectEvent is initiated, whole page life cycle is executed including Page_Load. So, it .Collapsed is set to true during DirectEvent also.

    To avoid this please wrap Page_Load code in
    if (!X.IsAjaxRequest)
    {
        this.FieldSet1.Collapsed = true;
    }
    Full Example
    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!X.IsAjaxRequest)
            {
                this.FieldSet1.Collapsed = true;
            }
        }
    
        protected void Button_Click(object sender, DirectEventArgs e)
        {
            X.MessageBox.Alert("Is collapsed?", this.FieldSet1.Collapsed.ToString()).Show();
        }
    </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:FieldSet 
            ID="FieldSet1" 
            runat="server" 
            Collapsible="true" 
            Width="200">
            <Items>
                <ext:TextField runat="server" />
            </Items>
        </ext:FieldSet>
        <ext:Button runat="server" Text="Is collapsed" OnDirectClick="Button_Click" />
        </form>
    </body>
    </html>

Similar Threads

  1. Replies: 6
    Last Post: Dec 07, 2011, 12:55 PM
  2. [1.0] Rowexpander collapsed property missing
    By SouthDeveloper in forum 1.x Help
    Replies: 3
    Last Post: Feb 19, 2010, 4:51 PM
  3. Replies: 1
    Last Post: May 27, 2009, 5:23 PM
  4. Replies: 6
    Last Post: Jan 07, 2009, 8:31 AM
  5. [CLOSED] Fieldset Cls property does'nt work
    By amitpareek in forum 1.x Legacy Premium Help
    Replies: 6
    Last Post: Dec 08, 2008, 4:53 AM

Tags for this Thread

Posting Permissions