Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

CollapsiblePanelExtender Panel is opening but is not collapsing

Avatar of christ2
christ2 asked on
.NET Programming
3 Comments1 Solution1041 ViewsLast Modified:
Hello I have a CollapsiblePanelExtender added in the code behind.
It works, the content panel opens clicking on the header. Picture is switching.
until this point everything is fine. But when I click to close the contentpanel. The panel does not close.
Someone who can give me a idea, what I missed.

if I add this Javascript  and a event to the image
oImage.OnClientClick = "return ExpandCollapse();";

 "function ExpandCollapse()"+
        "{" +          
        "  var collPanel = $find('CollapsiblePanelExtender1');" +
        "    if (collPanel.get_Collapsed())"+
        "        collPanel.set_Collapsed(false);"+
        "    else" +
        "        collPanel.set_Collapsed(true); }    "+  

the panel close but a sec later it opens again.

----- Here the code -------------------------------------------------------------------------

addLiteral("<td class='labelsmall' colspan='7'>");

      #region CollapsedPanel

      // int scriptmanager
      ScriptManager oScriptManager = new ScriptManager();
      oScriptManager.ID = "ScriptManager1";

      // PlaceHolder init
      PlaceHolder oPlaceHolder = new PlaceHolder();
      // Ein Panel für den Titel
      Panel oPanelTitle = new Panel();
      oPanelTitle.ID = "pnlTitle";
      oPanelTitle.CssClass = "cpHeader";

      // Imagebutton, der den Collapse steuert
      System.Web.UI.WebControls.ImageButton oImage = new  System.Web.UI.WebControls.ImageButton();
      oImage.ID="PanelTitleImage" ;
      oImage.ImageUrl="~/pic/expand.jpg" ;
      // Header Label
      Label oLabel = new Label();
       oLabel.ID   = "PanelTitleLabel";
      // ContentPanel erzeugen
      Panel oPanelContent = new Panel();
      oPanelContent.ID = "pnlContent";
      oPanelContent.CssClass = "cpBody";
    // Literal für den Content
      Literal oLiteral = new Literal();
      oLiteral.Text = "Inserire i dati manualmente ...";
      // CollapsiblePanelExtender erzeugen
      CollapsiblePanelExtender oCollapseExt = new CollapsiblePanelExtender();
oCollapseExt.ID = "CollapsiblePanelExtender1";
      oCollapseExt.TargetControlID  = "pnlContent";
      oCollapseExt.ExpandControlID  = "pnlTitle";
      oCollapseExt.CollapsedSize    = 0;
      oCollapseExt.CollapsedText    = " Show Help";
      oCollapseExt.ExpandedText     = " Hide Help";
      oCollapseExt.CollapsedImage   = "~/pic/expand.jpg";
      oCollapseExt.ExpandedImage    = "~/pic/collapse.jpg";
      oCollapseExt.Collapsed        = true;
      oCollapseExt.SuppressPostBack = true;
      oCollapseExt.ImageControlID   = "PanelTitleImage" ;
      oCollapseExt.TextLabelID      = "PanelTitleLabel";
      oCollapseExt.ClientState      = "true";
      oCollapseExt.AutoCollapse     = false;
      // die Controls dem Placeholder zuordnen

Avatar of christ2

Our community of experts have been thoroughly vetted for their expertise and industry experience.

This problem has been solved!
Unlock 1 Answer and 3 Comments.
See Answers