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
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?
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.
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
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:
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?
Jason241
Member
115 Points
23 Posts
Closing a CollapsiblePanelExtender from codebehind
May 23, 2006 01:20 AM|LINK
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 ThenCollapsiblePanelExtender.TargetProperties.Item(x).Collapsed =
True End If NextUpdatePanel1.Update()
End Subsburke_msft
Contributor
4396 Points
770 Posts
Microsoft
Re: Closing a CollapsiblePanelExtender from codebehind
May 23, 2006 07:25 PM|LINK
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 = ""
?
Jason241
Member
115 Points
23 Posts
Re: Closing a CollapsiblePanelExtender from codebehind
May 23, 2006 11:08 PM|LINK
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?
sburke_msft
Contributor
4396 Points
770 Posts
Microsoft
Re: Closing a CollapsiblePanelExtender from codebehind
May 24, 2006 12:59 AM|LINK
Jason241
Member
115 Points
23 Posts
Re: Closing a CollapsiblePanelExtender from codebehind
May 24, 2006 03:10 AM|LINK
When I took it out it didn't matter. I originally didn't have it in there.
joseph111780
Member
142 Points
29 Posts
Re: Closing a CollapsiblePanelExtender from codebehind
May 26, 2006 03:46 PM|LINK
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.
joseph111780
Member
142 Points
29 Posts
Re: Closing a CollapsiblePanelExtender from codebehind
May 26, 2006 04:51 PM|LINK
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 IfPureWeen
Participant
1221 Points
317 Posts
Re: Closing a CollapsiblePanelExtender from codebehind
Nov 08, 2006 06:54 AM|LINK
alright so now how does this work?
it appears now that the AjaxControlToolkit.CollapsiblePanelExtender no longer has this property exposed in the code behind
demwiz
Member
15 Points
3 Posts
Re: Closing a CollapsiblePanelExtender from codebehind
Nov 08, 2006 11:41 AM|LINK
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:
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?
CollapsiblePanel CollapsiblePanelExtender Behavior clientstate properties persist postback
David Anson
Star
8728 Points
1847 Posts
Microsoft
Re: Closing a CollapsiblePanelExtender from codebehind
Nov 16, 2006 04:00 PM|LINK
http://dlaa.me/
http://blogs.msdn.com/b/delay/
This posting is provided "AS IS" with no warranties, and confers no rights.