Here is the actual code I used, in case it might help someone make sense of out of all of this :)
ASPX:
<%@.PageLanguage="VB"AutoEventWireup="false"CodeFile="PanelTest.aspx.vb"Inherits="PanelTest" %>
<%@.RegisterAssembly="AtlasControlToolkit"Namespace="AtlasControlToolkit"TagPrefix="cc1" %>
<!DOCTYPEhtmlPUBLIC"-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<htmlxmlns="http://www.w3.org/1999/xhtml">
<headrunat="server">
<title>Untitled Page</title>
</head>
<body>
<formid="form1"runat="server">
<div>
<br/>
<br/>
<atlas:ScriptManagerID="scriptmanager1"runat="Server"EnablePartialRendering="true">
</atlas:ScriptManager>
<br/>
</div>
<cc1:CollapsiblePanelExtenderID="CollapsiblePanelExtender1"runat="server">
<cc1:CollapsiblePanelPropertiesCollapseControlID="Button1"ExpandControlID="Button1"TargetControlID="Panel1"
SuppressPostBack="true"Collapsed="True">
</cc1:CollapsiblePanelProperties>
</cc1:CollapsiblePanelExtender>
<atlas:UpdatePanelID="UpdatePanel1"runat="server"Mode="Always">
<ContentTemplate>
<asp:ButtonID="Button1"runat="server"Text="Button"/>
</ContentTemplate>
</atlas:UpdatePanel>
<atlas:UpdatePanelID="UpdatePanel2"runat="server"Mode="Always">
<ContentTemplate>
<asp:PanelID="Panel1"runat="server"Height="50px"Width="125px">
<asp:ButtonID="Button2"runat="server"Text="Button"/></asp:Panel>
</ContentTemplate>
</atlas:UpdatePanel>
</form>
</body>
</html>
Codebehind:
PartialClass PanelTest
Inherits System.Web.UI.Page
ProtectedSub Button2_Click(ByVal senderAsObject,ByVal eAs System.EventArgs)Handles Button2.Click
Me.CollapsiblePanelExtender1.GetTargetProperties(Me.Panel1).Collapsed =True
Me.CollapsiblePanelExtender1.GetTargetProperties(Me.Panel1).ClientState ="true"
EndSub
EndClass
If you're going this route, you probably don't want Button2 doing postbacks so it wouldn't even need a Click handler. Maybe try with a non-ASP.NET button ("<input type="button" value="Button" />") to see if that helps.
Actually, I do want button 2 doing postbacks as I plan to put some code under there, then close the panel after the code is executed. Button 1 however will not need one.
I will try that idea on button 1 (never know, it might work). In any case, thanks for the help.
Hi,
I am also facign similar problems as yours.I also have smilar code setup. I am having problems in programmatically collapsing and expanding Panels on a button click.The code in Button click does not do anything.The "pnlEmail" stays in the page and "pnlQuestions" does not expand. I have followed the general example as per FAQ 19 for Atlas. This is really weird as I really don't see any problem with the code.
Thanks
Kaundinya
ASPX Code:
<UpdatePanel>
<Panel id="pnlEmail">
<Button1>
<Panel id="pnlQuestions">
</UpdatePanel>
<atlasToolkit:CollapsiblePanelExtender ID="cpeEmail" runat="server">
<atlasToolkit:CollapsiblePanelProperties
TargetControlID="pnlEmail"
ScrollContents="False"
ExpandDirection="Vertical"
ExpandedText =""
ID="cpeEmail1"
/>
</atlasToolkit:CollapsiblePanelExtender>
<atlasToolkit:CollapsiblePanelExtender ID="cpeQuestions" runat="server">
<atlasToolkit:CollapsiblePanelProperties
TargetControlID="pnlQuestions"
ScrollContents="False"
ExpandDirection="Vertical"
ExpandedText =""
ID="cpeQuestions1"
/>
</atlasToolkit:CollapsiblePanelExtender>
Button1_Click Code:
bool collapsed = true;
CollapsiblePanelProperties properties = cpeEmail.GetTargetProperties(pnlEmail);
if (properties != null)
{
properties.ClientState = "true"; // collapsed.ToString().ToLower();
properties.Collapsed = true;
}
//////Expand the Questions Panel
CollapsiblePanelProperties propertiesQuestions = cpeQuestions.GetTargetProperties(pnlQuestions);
if (propertiesQuestions != null)
{
propertiesQuestions.ClientState = "false";
propertiesQuestions.Collapsed = false;
properties.AutoExpand = true;
}
The previous post appears to be a duplicate ofhttp://forums.asp.net/thread/1415878.aspx and can probably best be addressed in its own thread instead of here.
Well, I tried your suggestion but on button 1 instead of button 2 and the behavior remains the same (button 2 doesn't collapse the panel).
The code is pretty much identical to the one above but I replaced:
<asp:ButtonID="Button1"runat="server"Text="Button"/>
with:
<inputtype="button"id="Button1"value="Button"/>
Button 1 still works with expanding and collapsing the panel, but not button 2 (which I left as an asp button since I will need it to execute some code before it collapses the panel.
PS Sorry for the delayed reply, I was busy the past few days :)
Okay, let's try something completely different (and simpler!). The below works in IE7 and FF:
<%@. Page Language="VB" AutoEventWireup="false" %><%@. Register Assembly="AtlasControlToolkit" Namespace="AtlasControlToolkit" TagPrefix="cc1" %><!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 id="Head1" runat="server"> <title>Untitled Page</title></head><body> <form id="form1" runat="server"> <div> <atlas:ScriptManager ID="scriptmanager1" runat="Server" /> <asp:Button ID="Button1" runat="server" Text="Button" /> <asp:Panel ID="Panel1" runat="server" Height="50px" Width="125px" BackColor="lavenderBlush"> <asp:Button ID="Button2" runat="server" Text="Button" OnClientClick="$('Button1').click(); return false;" /> </asp:Panel> <cc1:CollapsiblePanelExtender ID="CollapsiblePanelExtender1" runat="server"> <cc1:CollapsiblePanelProperties CollapseControlID="Button1" ExpandControlID="Button1" TargetControlID="Panel1" SuppressPostBack="true" Collapsed="True"> </cc1:CollapsiblePanelProperties> </cc1:CollapsiblePanelExtender> </div> </form></body></html>
Thanks, that indeed worked. I had to return true for the OnClientClick in order to execute the code on the event handler for the button in the code behind page, and it works as intended. Again, thanks.
No comments:
Post a Comment