Friday, July 18, 2008

Collapsible Panel extender CSS issue with Moss

Since I start implementing AJAX in moss, we are facing problem with most of the every control.
Asp.Net Ajax Controls is not easy to integrate with SharePoint.

In my previous post I solve problem with Tab Container with header display issue.

Now, here I’m explaining collapsible panel extender issue with SharePoint /Moss.
I am facing a problem that Collapsible Panel is not collapsing in SharePoint/Moss webpart.

By default it should hide the content area and on clicking on the header it should expand the content area.
But it is not working as easily like it is working in Simple Asp.Net application.

In my case collapsible panel is not hiding content, it just flicker and again come to the same position as it is in default position.

So from this behavior what I think is that if it is (same code) working in standard asp.net than there is not any problem in control but because it is rendering in SharePoint and because of SharePoint’s JavaScript/JS and its CSS it conflicting with something while rendering.

So first I start with CSS because defiantly it’s easy.

Now if you check your AjaxControlToolKit -- > sample website --> StyleSheet.css

You will find two css class under “/*CollapsiblePanel*/”

One is “.collapsePanel”
Other is “.collapsePanelHeader”

So I used it in my .ascx (sorry I forget to explain that I’m using user control for webpart)
By adding <style type="text/css" > </style> tag.

As we are not facing any problem in header so there is no need to touch that CSS.

So by trial and error I found one solution.

I have to add in the div of content panel
style="height:0px;position:absolute;”

And have to set two properties of “CollapsiblePanelExtender”
CollapsedSize="0"
ExpandedSize="700"


Here is the working code


<style type="text/css" >
/* IE theme – Backgrounds */
.collapsePanel {
background-color:white;
overflow:hidden;
/*height:0px;
position:absolute;*/
}

.collapsePanelHeader{
width:100%;
height:30px;
background-image: url(images/bg-menu-main.png);
background-repeat:repeat-x;
color:#FFF;
font-weight:bold;
}
</style>

<asp:Panel ID="Panelheader" runat="server" style="cursor:pointer;" >
<div id="div1" runat="server" >want to check its working or not ?</div>
</asp:Panel>
<br />
<asp:Panel id="Panelcontent" runat="server" >
<div id="div2" style="height:0px;position:absolute;" >
your data will go here
<br />
<br />
<br />
it's working ....
</div>
</asp:Panel>
<cc1:CollapsiblePanelExtender
ID="CPanelGeneralInformation"
runat="server"
TargetControlID="Panelcontent"
CollapseControlID="Panelheader"
ExpandControlID="Panelheader"
Collapsed="true"
SuppressPostBack="true"
AutoCollapse="false"
AutoExpand="false"
ScrollContents="false"
ExpandDirection="vertical"
CollapsedSize="0"
ExpandedSize="700"
>
</cc1:CollapsiblePanelExtender>

17 comments:

Manoj Kr. Garg said...

Thanks a lot.. was looking for same..

--
Manoj Garg

qteJane said...

Half a day's hard work took me eventually here & pb solved!
Although I was using overflow:hidden on my panel, it still showed up expanded (but only in IE7, in Mozilla it worked and displayed just fine!).
The trick was placing your div inside the panel with the very important style attributes style='height:0px;position:absolute'.

Rumesh said...

style='height:0px;position:absolute'.

Yes. Yes. It works. Thank you very much

Anonymous said...

Worked great. thank you.

Unknown said...

Can you tell me how to do this programatically?

Unknown said...

Can you tell me how I can achieve the same programatically

Unknown said...

Hi
Thanks for the post. It solved my problem too.. now it is expanding the content panel but as I apply "position:absolute" to the table in the content panel, the border of the content panel disappears.. I m not able to give border to the content panel. Please help me...

SharePoint Kings said...

naga,

what you want to do programatically?

SharePoint Kings said...

shweta,

because of "position:absolute" border should not be removed. that might be something else that is effecting.

try to remove position and check whether border is coming or not, then also try apply some style to give border explicitly.

Anonymous said...

thanks for the post. I have one question/problem:

Since position for the panel is absolute now, you can't have any other control or webpart below the panel right?

Ali

SharePoint Kings said...

@Ali You can have it panel absolute will not affect.

Oussama Dinia said...

Awsome, thank you very much

JAS said...

thanks. But by providing ExpandedSize to the cpe, it always opens to this size. How can I made this expanded size dynamic?

SharePoint Kings said...

we face same issue, but you can set dynamic size by code.

but we still not found how to make it auto increase if controls are bigger.

ddubs said...

I am tryin to create a Collapse Menu for Shrepoint Site in the left menu side of the page


Its a Tasker button that u click & it go right to left .

Where in Sharepoint Designer 2010
in Web Part Can I create this????

SharePoint Kings said...

ddubs,

can you please explain in details what you are trying to do and where SharePoint designer comes into picture.

Pravesh Singh said...

This is best one article so far I have read online. I would like to appreciate you for making it very simple and easy. I have found another nice post related to this post over the internet which also explained very well. For more details you may check it by visiting this url....

Ajax Toolkit CollapsiblePanelExtender Control in ASP.Net

Thanks

Thanks




Share your SharePoint Experiences with us...
As good as the SharePointKings is, we want to make it even better. One of our most valuable sources of input for our Blog Posts comes from ever enthusiastic Visitors/Readers. We welcome every Visitor/Reader to contribute their experiences with SharePoint. It may be in the form of a code stub, snippet, any tips and trick or any crazy thing you have tried with SharePoint.
Send your Articles to sharepointkings@gmail.com with your Profile Summary. We will Post them. The idea is to act as a bridge between you Readers!!!

If anyone would like to have their advertisement posted on this blog, please send us the requirement details to sharepointkings@gmail.com