Solved

Collapsable panel in asp.net

Posted on 2016-07-28
9
57 Views
Last Modified: 2016-08-03
dear all


i have 2 collapsable panel on asp.net web forms
i need upon clicking on teh first collapsabe panel , to open panel1 and hide panel 2
upon clickingon the second collapsable panel to open panel 2 and hide panel 1
also i need to change the bachkround of the selected collapsable panel so i can know on whick button i clicked
0
Comment
Question by:pamela rizk
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
9 Comments
 
LVL 19

Expert Comment

by:Manoj Patil
ID: 41734254
Try This
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="TestBothVerticalAndHorizontal.aspx.vb"
    Inherits="SoluTest_CollapsiblePanel.TestBothVerticalAndHorizontal" %>


<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" 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 runat="server">
    <title></title>


    <script type="text/javascript">


        // Animation used to expand/collapse the panel
        this._currentAnimation = null;
        this._anotherAnimation = null;


        this._isBothDisplay = true;


        this._maxHeight = null;
        this._halfHeight = null;
        this._minHeight = null;


        function pageLoad() {


            this._maxHeight = 190;
            this._halfHeight = this._maxHeight / 2;
            this._minHeight = 0;


        }


        function TitleClick(sender) {


            if (sender == $get("TitlePanel2")) {
                var currentContent = $get("ContentPanel2");
                var anotherContent = $get("ContentPanel3");
            } else {
                var currentContent = $get("ContentPanel3");
                var anotherContent = $get("ContentPanel2");
            }


            this._currentAnimation = new AjaxControlToolkit.Animation.LengthAnimation(currentContent, .15, 25, 'style', null, 0, 0, 'px');
            this._anotherAnimation = new AjaxControlToolkit.Animation.LengthAnimation(anotherContent, .15, 25, 'style', null, 0, 0, 'px');


            this._currentAnimation.set_propertyKey('height');
            this._anotherAnimation.set_propertyKey('height');


            this._currentAnimation.add_ended(function() { onAnimateComplete(currentContent); });


            this._isBothDisplay = !this._isBothDisplay;


            if (this._isBothDisplay) {


                currentContent.style.display = "";
                anotherContent.style.display = "";


                var currentStartHeight;
                var anotherStartHeight;


                if (currentContent.style.height && anotherContent.style.height) {
                    currentStartHeight = currentContent.style.height;
                    anotherStartHeight = anotherContent.style.height;
                } else {
                    currentStartHeight = this._minHeight;
                    anotherStartHeight = this._maxHeight;
                }


                // Resume the original state.
                // setup the animation state
                this._anotherAnimation.set_startValue(anotherStartHeight);
                this._anotherAnimation.set_endValue(this._halfHeight);


                this._currentAnimation.set_startValue(currentStartHeight);
                this._currentAnimation.set_endValue(this._halfHeight);


                // do it!
                this._currentAnimation.play();
                this._anotherAnimation.play();


            } else {


                //Collapse the current ContentPanel and expand the other ContentPanel.
                // setup the animation state
                this._currentAnimation.set_startValue(this._halfHeight);
                this._currentAnimation.set_endValue(this._minHeight);


                this._anotherAnimation.set_startValue(this._halfHeight);
                this._anotherAnimation.set_endValue(this._maxHeight);


                // do it!
                this._currentAnimation.play();
                this._anotherAnimation.play();
            }
        }




        function onAnimateComplete(current) {
            if (!this._isBothDisplay) {
                current.style.display = "none";
            }
        }


    </script>


    <style type="text/css">
        .collapseContainer
        {
            height: 250px;
        }
        /* The Horizontal section */.collapsePanelHeaderHorizontal
        {
            width: 30px;
            height: 245px;
            color: Yellow;
            background-color: #000080;
            font-weight: bold;
            float: left;
            padding: 5px;
            cursor: pointer;
            vertical-align: middle;
        }
        .collapsePanelHorizontal
        {
            border: thin solid #0000FF;
            height: 250px;
            background-color: white;
            overflow: visible;
            float: left;
        }
        /* The Vertical section */.collapsePanelHeaderVertical
        {
            height: 20px;
            color: Yellow;
            background-color: #000080;
            font-weight: bold;
            float: none;
            padding: 5px;
            cursor: pointer;
            vertical-align: middle;
        }
        .collapsePanelVertical
        {
            height: 95px;
            border: thin solid #0000FF;
            background-color: white;
            overflow: visible;
            float: none;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <div class="collapseContainer">
        <asp:ScriptManager ID="ScriptManager1" runat="server" />
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>
                <asp:Panel ID="HoriTitle1" runat="server" CssClass="collapsePanelHeaderHorizontal">
                    <asp:Image ID="HoriImage1" runat="server" ImageAlign="Bottom" ImageUrl="~/Images/expand_blue.jpg" />Ajax
                    <asp:Label ID="HoriLabel1" runat="server" Text="Label" Style="float: right;">(Show details)</asp:Label>
                </asp:Panel>
                <asp:Panel ID="HoriContent1" runat="server" CssClass="collapsePanelHorizontal">
                    ASP.NET AJAX is a free framework for building a new generation of richer, more interactive,
                    highly personalized cross-browser web applications.
                </asp:Panel>
                <cc1:CollapsiblePanelExtender ID="HoriCPE1" runat="server" TargetControlID="HoriContent1"
                    ExpandControlID="HoriTitle1" CollapseControlID="HoriTitle1" TextLabelID="HoriLabel1"
                    ExpandedText="(hide details)" CollapsedText="(show details)" CollapsedImage="~/Images/expand_blue.jpg"
                    ExpandedImage="~/Images/collapse_blue.jpg" SuppressPostBack="true" ImageControlID="HoriImage1"
                    Collapsed="false" EnableViewState="true" CollapsedSize="0" ExpandDirection="Horizontal"
                    ExpandedSize="250">
                </cc1:CollapsiblePanelExtender>
                <asp:Panel ID="HoriContent2" runat="server">
                    <asp:Panel ID="TitlePanel2" runat="server" CssClass="collapsePanelHeaderVertical"
                        onclick="TitleClick(this)">
                        <asp:Image ID="Image2" runat="server" ImageAlign="Right" ImageUrl="~/Images/expand_blue.jpg" />Ajax
                        <asp:Label ID="Label2" runat="server" Text="Label">(Show details)</asp:Label>
                    </asp:Panel>
                    <asp:Panel ID="ContentPanel2" runat="server" CssClass="collapsePanelVertical">
                        The Content2 area.
                    </asp:Panel>
                    <asp:Panel ID="ContentPanel3" runat="server" CssClass="collapsePanelVertical">
                        The Content3 area.ASP.NET AJAX is a free framework for building a new generation
                        of richer, more interactive, highly personalized cross-browser web applications.
                    </asp:Panel>
                    <asp:Panel ID="TitlePanel3" runat="server" CssClass="collapsePanelHeaderVertical"
                        onclick="TitleClick(this)">
                        <asp:Image ID="Image3" runat="server" ImageAlign="Right" ImageUrl="~/Images/collapse_blue.jpg" />Ajax
                        <asp:Label ID="Label3" runat="server" Text="Label">(Show details)</asp:Label>
                    </asp:Panel>
                </asp:Panel>
                <cc1:CollapsiblePanelExtender ID="HoriCPE2" runat="server" TargetControlID="HoriContent2"
                    ExpandControlID="HoriTitle1" CollapseControlID="HoriTitle1" SuppressPostBack="true"
                    ImageControlID="HoriImage1" Collapsed="true" EnableViewState="true" CollapsedSize="600"
                    ExpandDirection="Horizontal" ExpandedSize="850">
                </cc1:CollapsiblePanelExtender>
            </ContentTemplate>
        </asp:UpdatePanel>
    </div>
    </form>
</body>
</html>

Open in new window

0
 

Author Comment

by:pamela rizk
ID: 41734285
thank you but this is not what i am asking for :
i  have the below code:
this is the first panel:
 <asp:Panel runat="server" ID="click_Indexpanel" Style="height: 130px">


                                            <asp:Image ID="Img_panel_left" runat="server" Style="cursor: pointer" ImageUrl="~/Images/MenuImages/VerticalLeft-en-ico.png" />


                                            <div class="verticalLabel" style="top: -64px; right: 8px; left: -5px; position: relative; text-align: center;">
                                                <asp:Label runat="server" ID="Lbl_verticalIndextext" Text="vertical text"
                                                    Font-Size="8pt" Font-Names="Tahoma" Font-Bold="true" ForeColor="White" Style="cursor: pointer"></asp:Label>
                                            </div>
                                        </asp:Panel>
                                        <AjaxControlToolkit:CollapsiblePanelExtender
                                            ID="collapsible_navigation"
                                            runat="server"
                                            CollapseControlID="click_Indexpanel"
                                            TargetControlID="Index_panel"
                                            ExpandControlID="click_Indexpanel"
                                            Collapsed="true"
                                            ExpandDirection="Horizontal">
                                        </AjaxControlToolkit:CollapsiblePanelExtender>

this is teh code of teh second panel
<asp:Panel runat="server" ID="click_Toolboxpanel" Style="height: 130px">

                                            <asp:Image ID="Img_Toolbox" runat="server" Style="cursor: pointer"
                                                ImageUrl="~/Images/MenuImages/VerticalLeft-en-ico.png" />

                                            <div class="verticalLabel" style="top: -64px; right: 8px; left: -5px; position: relative; text-align: center;">
                                                <asp:Label runat="server" ID="Lbl_verticaltoolboxtext"
                                                    Text="vertical text"
                                                    Font-Size="8pt" Font-Names="Tahoma" Font-Bold="true"
                                                    ForeColor="White" Style="cursor: pointer"></asp:Label>
                                            </div>
                                        </asp:Panel>
                                        <AjaxControlToolkit:CollapsiblePanelExtender
                                            ID="Cpe_Toolbox"
                                            runat="server"
                                            CollapseControlID="click_Toolboxpanel"
                                            TargetControlID="Toolbox_Panel"
                                            ExpandControlID="click_Toolboxpanel"
                                            Collapsed="true"
                                            ExpandDirection="Horizontal">
                                        </AjaxControlToolkit:CollapsiblePanelExtender>

and these are panels that should shown upon clicking on collapsable:
<asp:Panel ID="Index_panel" runat="server" CssClass="PopupPanelCurveStyle_N" BackColor="White"
                                                Style="min-width: 300px; display: none; padding: 5px; position: relative; z-index: 9999999999999999999">
                                                index
                                            </asp:Panel>

<asp:Panel ID="Toolbox_Panel" runat="server" CssClass="PopupPanelCurveStyle_N" BackColor="White"
                                                Style="display: none; padding: 5px;position: relative; z-index: 9999999999999999999">
Toolbox
</asp:Panel>

Open in new window



i need upon clicking on first collapsable to open its panel ionly and hide the panel that shown upon clicking on the second collapsable
0
 
LVL 19

Assisted Solution

by:Manoj Patil
Manoj Patil earned 500 total points
ID: 41734476
Check this working example
Accordian.zip

This is very light weight and easy to use accordian.
You can easily integrate this in your .aspx page
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Accepted Solution

by:
pamela rizk earned 0 total points
ID: 41734483
thank you but i solved my problem  upon adding in javascript a collapsed event where i collapse all other collapsable panels.
and this solve my problem
below is the code:

function pageLoad() {
            $find("collapsible_navigation").add_collapsed(onIndexcollapsed);
            $find("collapsible_navigation").add_expanded(onIndexexpanded);

            $find("collapsible_Toolbox").add_expanded(onToolboxexpanded);
            $find("collapsible_Toolbox").add_collapsed(onToolboxcollapsed);
        }
 function onToolboxexpanded() {
            $get("<%=ToolboxPanel.ClientID%>").style.display = "block";
            $get("<%=Indexpanel.ClientID%>").style.display = "none";
            var colPanel = $find("collapsible_navigation");
            colPanel.set_Collapsed(true);

            
         }
        function onIndexexpanded() {
            $get("<%=Indexpanel.ClientID%>").style.display = "block";
            $get("<%=ToolboxPanel.ClientID%>").style.display = "none";
            var colPanel = $find("collapsible_Toolbox");
            colPanel.set_Collapsed(true);
            
        }

        function onIndexcollapsed() {
            $get("<%=Indexpanel.ClientID%>").style.display = "none";
           
        }
        
        function onToolboxcollapsed() {
            $get("<%=ToolboxPanel.ClientID%>").style.display = "none";
           
            
        }

Open in new window

0
 
LVL 19

Expert Comment

by:Manoj Patil
ID: 41734487
The sample which I have given is working
0
 

Author Comment

by:pamela rizk
ID: 41734594
yes but it is not what i want
0
 
LVL 19

Expert Comment

by:Manoj Patil
ID: 41734627
The sample which was given in attachment is the exactly thing which you want
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question