Sitefinity CMS

Wrapping RadControls in a User Control Send comments on this topic.

Glossary Item Box

 

Master pages are used by pages for any pre-set functionality.  One of the options in Sitefinity is to integrate the award-winning RadControls, provided by Telerik. This topic will demonstrate how to implement a RadPanelbar in a master page.

For more information on how to create a master page, see Creating and Importing Master Pages.

 

The following MasterPage.master is a master page file. It references a RadPanelbar which binds to a SiteMapDataSource control. On each ItemDataBound, it checks the SiteMap to see if the panel item represents the current node (SiteMap.CurrentNode). If this is the case, the panel item and its parents are open to display the current position of the user on the SiteMap.

MasterPage.master Copy Code
<%@ Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage.master.cs" Inherits="App_Master_MasterPage" %>
<
%@ Register Assembly="RadMenu.Net2" Namespace="Telerik.WebControls" TagPrefix="radM" %>
<
%@ Register Assembly="RadPanelbar.Net2" Namespace="Telerik.WebControls" TagPrefix="radP" %>
<
!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
 
private void ItemDataBound(object sender, EventArgs e)
 {
   if (SiteMap.CurrentNode != null)
   {
     RadPanelItem item = ((RadPanelbar)sender).FindItemByUrl(Page.ResolveUrl(SiteMap.CurrentNode.Url));
     if (item != null)
     {
       item.Selected = true;
       RadPanelItem parent = item.Parent as RadPanelItem;
       while (parent != null)
       {
         parent.Expanded = true;
         parent = parent.Parent as RadPanelItem;
       }
     }
   }
 }
</script>
<
html xmlns="http://www.w3.org/1999/xhtml" >
<
head id="Head1" runat="server">
 
<title>Untitled Page</title>
 
<meta http-equiv="content-type" content="text/html; charset="utf-8" />    
</head>
<
body>
 
<form ID="form1" runat="server">
 
<div class="cmsWrapper">
   
<asp:SiteMapDataSource ID="sitemap" runat="server" ShowStartingNode="false" />
   
<radP:RadPanelbar Skin="WebBlue" ID="tabStrip" runat="server" DataSourceID="sitemap" OnItemDataBound="ItemDataBound"></radP:RadPanelbar>
 
</div>
 
</form>
</
body>
</
html>

 

There are different skins applicable to RadPanelbar. Some are "Golden", "Telerik", "Web20", "System". Online Demos are available at RadPanelbar Skins.

 

The result of applying the above code is visible in the screenshot (see Figure 1) and this RadPanelbar will appear on each page that has set its template to be the MasterPage master page:

Figure 1