Panel collapse/exapand from Markup but not Codebehind?

  1. #1

    Panel collapse/exapand from Markup but not Codebehind?

    For some reason, the purely Codebehind solution does not work. Panel1 will expand/collapse correctly every time, but Panel2 will not. It only collapse, but never expand. Can you tell me how to get the purely Codebehind solution to work? Thanks.

    Codebehind:

    Partial Class PanelTest2
        Inherits System.Web.UI.Page
    
        Dim Panel2 As Coolite.Ext.Web.Panel
    
        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            Dim btn As New Coolite.Ext.Web.Button
            With btn
                .Text = "Collapse"
            End With
            Controls.Add(btn)
            Panel2 = New Coolite.Ext.Web.Panel
            With Panel2
                .Title = "Test Panel"
                .Collapsible = True
                .Height = Unit.Pixel(500)
            End With
            Controls.Add(Panel2)
            AddHandler btn.AjaxEvents.Click.Event, AddressOf Click_Event
        End Sub
    
        Protected Sub Click_Event(ByVal sender As Object, ByVal e As Coolite.Ext.Web.AjaxEventArgs)
            If Not Panel2.Collapsed Then
                Panel2.Collapse()
            Else
                Panel2.Expand()
            End If
            If Not Panel1.Collapsed Then
                Panel1.Collapse()
            Else
                Panel1.Expand()
            End If
        End Sub
    
    End Class
    Markup:

    <%@ Page Language="VB" AutoEventWireup="false" CodeFile="PanelTest2.aspx.vb" Inherits="PanelTest2" %>
    
    <%@ 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">
    
    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
        <title>Untitled Page</title>
    </head>
    <body>
        <form id="form1" runat="server">
        
            <ext:ScriptManager ID="ScriptManager1" runat="server">
            </ext:ScriptManager>
            <br />
            <ext:Panel ID="Panel1" runat="server" Height="300" Title="Title" Collapsible="true">
                <Body>
                </Body>
            </ext:Panel>
            &amp;nbsp;
        
        
    
        </form>
    </body>
    </html>
  2. #2

    RE: Panel collapse/exapand from Markup but not Codebehind?

    Hi,

    You need to add controls to the*


    Me.Page.Form.Controls
    *


    You added to the Page.Controls collection therefore panel state didn't submit own state
  3. #3

    RE: Panel collapse/exapand from Markup but not Codebehind?

    Thanks, that did it. Please mark as solved.
  4. #4

    RE: Panel collapse/exapand from Markup but not Codebehind?

    Hi dbassett74,

    Just a quick something I noticed, you can use the .ToggleCollapse() Method to tighten up your code during the "Click_Event".*


    Example


    this.Panel1.ToggleCollapse();
    this.Panel2.ToggleCollapse();

    Hope this helps.


    Geoffrey McGill
    Founder

Similar Threads

  1. [CLOSED] [1.0]Convert markup DirectEvent to codebehind
    By betamax in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: May 19, 2010, 11:31 AM
  2. Replies: 6
    Last Post: Apr 30, 2010, 2:57 PM
  3. C# Code in Markup-Script-Tag or Codebehind
    By macap in forum Open Discussions
    Replies: 5
    Last Post: Apr 07, 2010, 3:58 AM
  4. Why use Markup instead of Codebehind?
    By dbassett74 in forum 1.x Help
    Replies: 1
    Last Post: Apr 21, 2009, 7:51 PM
  5. Prb: Moving objects from codebehind til markup
    By plykkegaard in forum 1.x Help
    Replies: 1
    Last Post: Mar 22, 2009, 2:16 PM

Posting Permissions