Closing a CollapsiblePanelExtender from codebehind

Rate It (3)

Last post 10-15-2009 9:11 AM by celoftis. 16 replies.

Sort Posts:

  • Closing a CollapsiblePanelExtender from codebehind

    05-22-2006, 9:20 PM
    • Member
      115 point Member
    • Jason241
    • Member since 03-26-2006, 5:43 PM
    • Posts 23

    I have 5 panels where I would like only one open at a time.   So I use a postback event to test and close the panel's as follows:  Problem is that it has no effect.  I used a update panel because surpressing the postback on the extender dosen't allow me to capture the event.  Maybe I am going about it wrong.   

    Protected Sub LinkButton1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles LinkButton1.Click

    Dim x As Integer

    For x = 0 To CollapsiblePanelExtender.TargetProperties.Count - 1

    If CollapsiblePanelExtender.TargetProperties.Item(x).Collapsed = False Then

    CollapsiblePanelExtender.TargetProperties.Item(x).Collapsed =

    True

    End If

    Next

    UpdatePanel1.Update()

    End Sub

     

  • Re: Closing a CollapsiblePanelExtender from codebehind

    05-23-2006, 3:25 PM
    • Contributor
      4,346 point Contributor
    • sburke_msft
    • Member since 04-04-2006, 7:28 PM
    • Redmond, WA
    • Posts 770
    • AspNetTeam

    This might be because the CollapsiblePanel is saving it's state before it closes.  What happens if you add this line:

     

    CollapsiblePanelExtender.TargetProperties(x).ClientState = ""

     

    ?

    Don't forget, this posting is provided "AS IS" with no warranties, and confers no rights.
  • Re: Closing a CollapsiblePanelExtender from codebehind

    05-23-2006, 7:08 PM
    • Member
      115 point Member
    • Jason241
    • Member since 03-26-2006, 5:43 PM
    • Posts 23

    Ok I added the above statment.  Did not make a difference.   When I step through it, it does change the property but reverts back when the page gets loaded.  I also tried setting the updatePanel's EnableViewState to False.  Same result.   The panel that I am expanding get expanded prior to the postback event.  Is it possible that it doesn't work due to it occuring to late in that cycle?

     

  • Re: Closing a CollapsiblePanelExtender from codebehind

    05-23-2006, 8:59 PM
    • Contributor
      4,346 point Contributor
    • sburke_msft
    • Member since 04-04-2006, 7:28 PM
    • Redmond, WA
    • Posts 770
    • AspNetTeam
    Does this work without the UpdatePanel?
    Don't forget, this posting is provided "AS IS" with no warranties, and confers no rights.
  • Re: Closing a CollapsiblePanelExtender from codebehind

    05-23-2006, 11:10 PM
    • Member
      115 point Member
    • Jason241
    • Member since 03-26-2006, 5:43 PM
    • Posts 23

    When I took it out it didn't matter.   I originally didn't have it in there. 

     

     

     

  • Re: Closing a CollapsiblePanelExtender from codebehind

    05-26-2006, 11:46 AM
    • Member
      142 point Member
    • joseph111780
    • Member since 05-26-2006, 3:09 PM
    • Posts 29

    Have you found a workaround/resolution yet for this issue?

    I've tried both CollapsiblePanelExtender1.TargetProperties(0).Collapsed = True and I've tried CollapsiblePanelExtender1.GetTargetProperties(Panel1).Collapsed = True within my button click event and neither work.  When I click the button it appears that it collapses the panel and then immediatly expands it again.  I've tried setting the ClientState = "" but that didn't seem to help either.

  • Re: Closing a CollapsiblePanelExtender from codebehind

    05-26-2006, 12:51 PM
    • Member
      142 point Member
    • joseph111780
    • Member since 05-26-2006, 3:09 PM
    • Posts 29

    Well, after messing a round for a couple more hours I've manage to accomplish what I desired.  My button_click event now includes the following code and functions correctly.

    If

    Me.CollapsiblePanelExtender1.GetTargetProperties(Me.Panel1).ClientState = "true" Then

    Me.CollapsiblePanelExtender1.GetTargetProperties(Me.Panel1).Collapsed = False

    Me.CollapsiblePanelExtender1.GetTargetProperties(Me.Panel1).ClientState = "false"

    Else

    Me.CollapsiblePanelExtender1.GetTargetProperties(Me.Panel1).Collapsed = True

    Me.CollapsiblePanelExtender1.GetTargetProperties(Me.Panel1).ClientState = "true"

    End If
  • Re: Closing a CollapsiblePanelExtender from codebehind

    11-08-2006, 2:54 AM
    • Participant
      1,221 point Participant
    • PureWeen
    • Member since 04-09-2005, 5:44 PM
    • Posts 317

    alright so now how does this work?

     it appears now that the AjaxControlToolkit.CollapsiblePanelExtender no longer has this property exposed in the code behind

     

  • Re: Closing a CollapsiblePanelExtender from codebehind

    11-08-2006, 7:41 AM
    • Member
      15 point Member
    • demwiz
    • Member since 08-02-2006, 2:07 AM
    • Posts 3

    Here's an example of how I've been trying to do it, maybe it will work for you.  Unfortunately, although it compiles and seems to run it doesn't actually seem to work for me.  In my case I'm trying to force the category to expand when a user clicks a command button to add an item to the category.

    My CollapsiblePanelExtender is defined in the ASP page like this:

    <ajaxToolkit:CollapsiblePanelExtender ID="cpeCategory" runat="server" TargetControlID="CategoryContentPanel"
            Collapsed="true" ExpandControlID="CategoryToggleImage" CollapseControlID="CategoryToggleImage"
            ExpandDirection="Vertical" ImageControlID="CategoryToggleImage" ExpandedImage="~/images/expand.gif"
            CollapsedImage="~/images/collapse.gif" SuppressPostBack="true" />

     
    And my code-behind (triggered on a LinkButton) is defined like this: 

    protected void Category_Command(object sender, FormViewCommandEventArgs e)
    {
    if (e.CommandName == "AddItem")
    {
    cpeCategory.Collapsed = false;
    cpeCategory.ClientState = false.ToString().ToLower();
    //Other processing here.. } }

     I've tried playing around with doing the ClientState set before, after, and both before and after setting the Collapsed property and it didn't make an impact.  I've also tried doing this via javascript but haven't had much success that direction since I'm not very familiar with it.

     Hopefully this code-example answers your question, and hopefully somebody else can point out what I'm doing wrong?

  • Re: Closing a CollapsiblePanelExtender from codebehind

    11-16-2006, 12:00 PM
    • Star
      8,710 point Star
    • David Anson
    • Member since 04-11-2006, 1:39 AM
    • Microsoft
    • Posts 1,842
    I think this is work item 5688.

    http://blogs.msdn.com/delay

    This posting is provided "AS IS" with no warranties, and confers no rights.
  • Re: Closing a CollapsiblePanelExtender from codebehind

    12-12-2006, 3:43 PM

    ok, the code found when you want to Collapse but When I want to expand the code doesn´t wanto to found..

     

     CollapsiblePanelExtender1.TargetProperties[0].Collapsed = false;

     

    What else I have to do? tks 

  • Re: Closing a CollapsiblePanelExtender from codebehind

    12-19-2006, 6:46 PM
    • Star
      8,710 point Star
    • David Anson
    • Member since 04-11-2006, 1:39 AM
    • Microsoft
    • Posts 1,842

    The relevant work item was fixed two releases ago. The sample code you have above is at least 4 releases old (.TargetProperties was removed some time ago). Please try again with the latest Toolkit, 61214.


    http://blogs.msdn.com/delay

    This posting is provided "AS IS" with no warranties, and confers no rights.
  • Re: Closing a CollapsiblePanelExtender from codebehind

    01-08-2007, 11:40 AM
    • Member
      32 point Member
    • dustwhirl
    • Member since 11-07-2006, 10:50 PM
    • St. Louis, MO
    • Posts 10

    Has anyone figured this out?

     I have two panels and the collapsiblepanelextender (cpe). One panel is used to expand/collapse, the other displays content. I also have a link button that I want to use to programatically collapse the content panel.

     I am using the most recent (RC) release.

     I tried setting the collapsed property of the cpe to false during the event handling for the link button. Also tried setting clientstate and suppressing postback, as well as placing in pre-render.

     I can't get the content panel to collapse using the link button.
     

    James
  • Re: Closing a CollapsiblePanelExtender from codebehind

    01-08-2007, 12:54 PM
    • Member
      32 point Member
    • dustwhirl
    • Member since 11-07-2006, 10:50 PM
    • St. Louis, MO
    • Posts 10

    Never mind

    See the sample code under (ToolkitTests/Manual/ClientStateLifecycle.aspx) in the AJAX Control Toolkit to solve this problem.

     I think I needed to have the "Collapsed" property assigned (I set it to false) to the control on the aspx page, because I had eveything else except that when it wasn't working.

     Works fine now...
     

    James
  • Re: Closing a CollapsiblePanelExtender from codebehind

    12-06-2007, 11:19 AM
    • Member
      8 point Member
    • hermer
    • Member since 05-18-2004, 5:02 PM
    • Posts 4

    I got a little confused with this post so here is my solution for anyone googling this answer up like i did!

    As of Ajax 1.0 build Dec 07 in code behind put the following to close a panel extender

      Me.CollapsiblePanelExtender1.Collapsed = True
      Me.CollapsiblePanelExtender1.ClientState = "True"

     


     

Page 1 of 2 (17 items) 1 2 Next >