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:

Troubleshooting
Research
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";
      this.Form1.Controls.Add(oScriptManager);

      // 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" ;
       oPanelTitle.Controls.Add(oImage);
     
      // Header Label
      Label oLabel = new Label();
       oLabel.ID   = "PanelTitleLabel";
       oPanelTitle.Controls.Add(oLabel);
     
      // 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 ...";
      oPanelContent.Controls.Add(oLiteral);
     
      // 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
      oPlaceHolder.Controls.Add(oPanelTitle);
      oPlaceHolder.Controls.Add(oPanelContent);
      oPlaceHolder.Controls.Add(oCollapseExt);

      this.Form1.Controls.Add(oPlaceHolder);
     
      addLiteral("</td>");
ASKER CERTIFIED SOLUTION
Avatar of christ2
christ2

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

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