We help IT Professionals succeed at work.

CollapsiblePanelExtender Panel is opening but is not collapsing

christ2
christ2 used Ask the Experts™
on
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>");
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Author

Commented:
I forgot to set the Zone. Its Visualstudio 2005 Net framework ASP.Net 2.0

Author

Commented:
I tested the code
for chrome. Problem as described. CSS is working
for Firefox.  Problem as described. CSS is NOT working
for IE8: IE opens the Content panel if I open the page and I can't close it. CSS is working.
Commented:
I have found itby myself:
I forgot
 oCollapseExt.CollapseControlID= "pnlTitle";