CollapseLinkButton
The CollapseLinkButton control can be used to provide a link that toggles showing and hiding (client side) and .NET server cotrol. In mojoPortal you can see example usage in the /Admin/SiteSettings.ascx where we use it to show and hide a section of configuration controls like LDAP settings that don't need to be changed very often and therefore clutter the page if they are all showing. It is nicer to hide the less frequently changed settings so that the user's attention is more drawn to the other settings.
Here is an example fragment from SiteSettings.ascx:
<mp:CollapseLinkButton runat="server" StartCollapsed="true" id="colLdap" ControlToCollapse="pnlLdapSettings" CollapseImageUrl="~/Data/SiteImages/minus.gif" ExpandImageUrl="~/Data/SiteImages/plus.gif" />
<mp:SiteLabel id="Sitelabel24" runat="server" ConfigKey="SiteSettingsLdapSettingsLabel"></mp:SiteLabel>
<asp:Panel ID="pnlLdapSettings" runat="server" CssClass="collapsiblepanel" SkinID="plain">
<div id="divUseLdap" runat="server" class="settingrow">
<mp:sitelabel id="lblUseLdapAuth" CssClass="settinglabel" ConfigKey="SiteSettingsUseLdapAuth" Runat="server"></mp:sitelabel>
<asp:checkbox id="chkUseLdapAuth" Runat="server"></asp:checkbox>
<mp:HelpLinkButton runat="server" id="HelpLinkButton28" HelpKey="sitesettingsuseldaphelp" ImageUrl="~/Data/SiteImages/FeatureIcons/help.gif" />
</div>
... more controls
</asp:Panel>
Here is the CollapseLinkButton by itself to take a closer look at the available properties:
<mp:CollapseLinkButton runat="server" id="colLdap"
StartCollapsed="true"
ControlToCollapse="pnlLdapSettings"
CollapseImageUrl="~/Data/SiteImages/minus.gif"
ExpandImageUrl="~/Data/SiteImages/plus.gif" />
Note that you can tell the control the server side id of the control to collapse. This can be an individual control but often its handy to put a bunch of controls in a Panel and then collapse or expand the whole panel to show or hide a group of controls.
You can also specifiy whether the initial state should be collapsed or not.
To use this control you need to put the mojoPortal.Web.Controls.dll into the bin folder of your application and set a reference to it. Then in your web.config file, in the system.web pages section add a control declaration like this:
<pages>
<controls>
<add tagPrefix="mp" namespace="mojoPortal.Web.Controls" assembly="mojoPortal.Web.Controls" />
</controls>
</pages>
Now you can use the mojoPortal Web Controls on any .aspx or .ascx file in your project without having to add a declaration at the top