webpartDataBound TabWidget is example
ascx file:
<%@ Control Language="C#" AutoEventWireup="true" Inherits="CMSWebParts_HSGA_TabWidget" CodeFile="~/CMSWebParts/HSGA/TabWidget.ascx.cs" EnableViewState="false" %>
<div class='tabs-section section-padding-sm'>
<div class='row'>
<div class='col-md-12'>
<div class='section-padding-sm'>
<div class='col-md-8 col-md-push-2' id="divPanelTitle" runat="server" visible="false">
<div class='text-center section-padding-bottom-xs'>
<h3>
<asp:Literal ID="ltrTabPanelTitle" runat="server"></asp:Literal>
</h3>
</div>
</div>
<div class='col-md-10 col-md-push-1 tabs-container'>
<div class='row'>
<div class='tabs'>
<ul class='nav nav-tabs' role='tablist'>
<asp:Repeater ID="rptTabHeader" runat="server">
<ItemTemplate>
<li class='<%# Container.ItemIndex == 0 ? "active" : "" %>' role='presentation'>
<a aria-controls='home' data-toggle='tab' href='#<%# Eval("NodeAlias") %>' role='tab'>
<span><%# Eval("TabContentTitle") %></span>
</a>
</li>
</ItemTemplate>
</asp:Repeater>
</ul>
</div>
<div class='tab-content'>
<asp:Repeater ID="rptTabContent" runat="server">
<ItemTemplate>
<div class='tab-pane <%# Container.ItemIndex == 0 ? "active" : "" %>' id='<%# Eval("NodeAlias") %>' role='tabpanel'>
<div class='row'>
<div class='col-sm-6'>
<ul class='list-unstyled'>
<asp:PlaceHolder ID="tabContentPlaceHolder1" runat="server">
<li>
<div class='icon-content'>
<asp:Literal ID="tabContentLiteralIcon1" runat="server"></asp:Literal>
</div>
<div class='text-content'>
<h4 class='heading heading-deep-blue'>
<asp:Literal ID="tabContentLiteralHeader1" runat="server"></asp:Literal>
</h4>
<p><asp:Literal ID="tabContentLiteralContent1" runat="server"></asp:Literal></p>
</div>
</li>
</asp:PlaceHolder>
</ul>
</div>
<div class='col-sm-6'>
<ul class='list-unstyled'>
<asp:PlaceHolder ID="tabContentPlaceHolder2" runat="server">
<li>
<div class='icon-content'>
<asp:Literal ID="tabContentLiteralIcon2" runat="server"></asp:Literal>
</div>
<div class='text-content'>
<h4 class='heading heading-deep-blue'>
<asp:Literal ID="tabContentLiteralHeader2" runat="server"></asp:Literal>
</h4>
<p><asp:Literal ID="tabContentLiteralContent2" runat="server"></asp:Literal></p>
</div>
</li>
</asp:PlaceHolder>
</ul>
</div>
<div class='col-sm-6'>
<ul class='list-unstyled'>
<asp:PlaceHolder ID="tabContentPlaceHolder3" runat="server">
<li>
<div class='icon-content'>
<asp:Literal ID="tabContentLiteralIcon3" runat="server"></asp:Literal>
</div>
<div class='text-content'>
<h4 class='heading heading-deep-blue'>
<asp:Literal ID="tabContentLiteralHeader3" runat="server"></asp:Literal>
</h4>
<p><asp:Literal ID="tabContentLiteralContent3" runat="server"></asp:Literal></p>
</div>
</li>
</asp:PlaceHolder>
</ul>
</div>
<div class='col-sm-6'>
<ul class='list-unstyled'>
<asp:PlaceHolder ID="tabContentPlaceHolder4" runat="server">
<li>
<div class='icon-content'>
<asp:Literal ID="tabContentLiteralIcon4" runat="server"></asp:Literal>
</div>
<div class='text-content'>
<h4 class='heading heading-deep-blue'>
<asp:Literal ID="tabContentLiteralHeader4" runat="server"></asp:Literal>
</h4>
<p><asp:Literal ID="tabContentLiteralContent4" runat="server"></asp:Literal></p>
</div>
</li>
</asp:PlaceHolder>
</ul>
</div>
<div class='col-sm-6'>
<ul class='list-unstyled'>
<asp:PlaceHolder ID="tabContentPlaceHolder5" runat="server">
<li>
<div class='icon-content'>
<asp:Literal ID="tabContentLiteralIcon5" runat="server"></asp:Literal>
</div>
<div class='text-content'>
<h4 class='heading heading-deep-blue'>
<asp:Literal ID="tabContentLiteralHeader5" runat="server"></asp:Literal>
</h4>
<p><asp:Literal ID="tabContentLiteralContent5" runat="server"></asp:Literal></p>
</div>
</li>
</asp:PlaceHolder>
</ul>
</div>
<div class='col-sm-6'>
<ul class='list-unstyled'>
<asp:PlaceHolder ID="tabContentPlaceHolder6" runat="server">
<li>
<div class='icon-content'>
<asp:Literal ID="tabContentLiteralIcon6" runat="server"></asp:Literal>
</div>
<div class='text-content'>
<h4 class='heading heading-deep-blue'>
<asp:Literal ID="tabContentLiteralHeader6" runat="server"></asp:Literal>
</h4>
<p><asp:Literal ID="tabContentLiteralContent6" runat="server"></asp:Literal></p>
</div>
</li>
</asp:PlaceHolder>
</ul>
</div>
</div>
</div>
</ItemTemplate>
</asp:Repeater>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
******************************cs file:
using System;
using System.Data;
using System.Collections;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CMS.PortalControls;
using CMS.DocumentEngine;
using CMS.Helpers;
using CMS.CustomTables;
public partial class CMSWebParts_HSGA_TabWidget : CMSAbstractWebPart
{
#region "Properties"
public string TabPanelTitle
{
get
{
return ValidationHelper.GetString(GetValue("TabPanelTitle"), "");
}
}
public string TabContentPath
{
get
{
return ValidationHelper.GetString(GetValue("TabContentPath"), "");
}
}
#endregion
#region "Methods"
/// <summary>
/// Content loaded event handler.
/// </summary>
public override void OnContentLoaded()
{
base.OnContentLoaded();
SetupControl();
}
/// <summary>
/// Initializes the control properties.
/// </summary>
protected void SetupControl()
{
if (this.StopProcessing)
{
// Do not process
}
else
{
if (!string.IsNullOrEmpty(TabPanelTitle))
{
ltrTabPanelTitle.Text = TabPanelTitle;
divPanelTitle.Visible = true;
}
string contentAliasPath = string.IsNullOrEmpty(TabContentPath) ? CurrentDocument.NodeAliasPath : TabContentPath;
DataSet ds = DocumentHelper.GetDocuments("HSGA.TabContent")
.Path(contentAliasPath, PathTypeEnum.Children)
.OrderBy("NodeOrder")
.Result;
if (!DataHelper.DataSourceIsEmpty(ds))
{
rptTabHeader.DataSource = ds;
rptTabHeader.DataBind();
rptTabContent.DataSource = ds;
rptTabContent.ItemDataBound += new RepeaterItemEventHandler(rptTabContent_ItemDataBound);
rptTabContent.DataBind();
}
}
}
protected void rptTabContent_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
DataRowView item = (DataRowView)e.Item.DataItem;
PlaceHolder placeholder1 = e.Item.FindControl("tabContentPlaceHolder1") as PlaceHolder;
placeholder1.Visible = false;
if (!String.IsNullOrEmpty(item.Row["TabContentHeader1"].ToString()))
{
Literal literalIconCss = e.Item.FindControl("tabContentLiteralIcon1") as Literal;
Literal literalHeader = e.Item.FindControl("tabContentLiteralHeader1") as Literal;
Literal literalContent = e.Item.FindControl("tabContentLiteralContent1") as Literal;
literalIconCss.Text = String.Format("<span aria-hidden='true' class='{0}'></span>", item.Row["TabIconCSS1"].ToString());
literalHeader.Text = item.Row["TabContentHeader1"].ToString();
//literalContent.Text = item.Row["TabContentText1"].ToString();
placeholder1.Visible = true;
}
PlaceHolder placeholder2 = e.Item.FindControl("tabContentPlaceHolder2") as PlaceHolder;
placeholder2.Visible = false;
if (!String.IsNullOrEmpty(item.Row["TabContentHeader2"].ToString()))
{
Literal literalIconCss = e.Item.FindControl("tabContentLiteralIcon2") as Literal;
Literal literalHeader = e.Item.FindControl("tabContentLiteralHeader2") as Literal;
Literal literalContent = e.Item.FindControl("tabContentLiteralContent2") as Literal;
//CSS
literalIconCss.Text = String.Format("<span aria-hidden='true' class='{0}'></span>", item.Row["TabIconCSS2"].ToString());
literalHeader.Text = item.Row["TabContentHeader2"].ToString();
//literalContent.Text = item.Row["TabContentText2"].ToString();
placeholder2.Visible = true;
}
PlaceHolder placeholder3 = e.Item.FindControl("tabContentPlaceHolder3") as PlaceHolder;
placeholder3.Visible = false;
if (!String.IsNullOrEmpty(item.Row["TabContentHeader3"].ToString()))
{
Literal literalIconCss = e.Item.FindControl("tabContentLiteralIcon3") as Literal;
Literal literalHeader = e.Item.FindControl("tabContentLiteralHeader3") as Literal;
Literal literalContent = e.Item.FindControl("tabContentLiteralContent3") as Literal;
//CSS
literalIconCss.Text = String.Format("<span aria-hidden='true' class='{0}'></span>", item.Row["TabIconCSS3"].ToString());
literalHeader.Text = item.Row["TabContentHeader3"].ToString();
//literalContent.Text = item.Row["TabContentText3"].ToString();
placeholder3.Visible = true;
}
PlaceHolder placeholder4 = e.Item.FindControl("tabContentPlaceHolder4") as PlaceHolder;
placeholder4.Visible = false;
if (!String.IsNullOrEmpty(item.Row["TabContentHeader4"].ToString()))
{
Literal literalIconCss = e.Item.FindControl("tabContentLiteralIcon4") as Literal;
Literal literalHeader = e.Item.FindControl("tabContentLiteralHeader4") as Literal;
Literal literalContent = e.Item.FindControl("tabContentLiteralContent4") as Literal;
//CSS
literalIconCss.Text = String.Format("<span aria-hidden='true' class='{0}'></span>", item.Row["TabIconCSS4"].ToString());
literalHeader.Text = item.Row["TabContentHeader4"].ToString();
//literalContent.Text = item.Row["TabContentText4"].ToString();
placeholder4.Visible = true;
}
PlaceHolder placeholder5 = e.Item.FindControl("tabContentPlaceHolder5") as PlaceHolder;
placeholder5.Visible = false;
if (!String.IsNullOrEmpty(item.Row["TabContentHeader5"].ToString()))
{
Literal literalIconCss = e.Item.FindControl("tabContentLiteralIcon5") as Literal;
Literal literalHeader = e.Item.FindControl("tabContentLiteralHeader5") as Literal;
Literal literalContent = e.Item.FindControl("tabContentLiteralContent5") as Literal;
//CSS
literalIconCss.Text = String.Format("<span aria-hidden='true' class='{0}'></span>", item.Row["TabIconCSS5"].ToString());
literalHeader.Text = item.Row["TabContentHeader5"].ToString();
//literalContent.Text = item.Row["TabContentText5"].ToString();
placeholder5.Visible = true;
}
PlaceHolder placeholder6 = e.Item.FindControl("tabContentPlaceHolder6") as PlaceHolder;
if (!String.IsNullOrEmpty(item.Row["TabContentHeader6"].ToString()))
{
Literal literalIconCss = e.Item.FindControl("tabContentLiteralIcon6") as Literal;
Literal literalHeader = e.Item.FindControl("tabContentLiteralHeader6") as Literal;
Literal literalContent = e.Item.FindControl("tabContentLiteralContent6") as Literal;
//CSS
literalIconCss.Text = String.Format("<span aria-hidden='true' class='{0}'></span>", item.Row["TabIconCSS6"].ToString());
literalHeader.Text = item.Row["TabContentHeader6"].ToString();
//literalContent.Text = item.Row["TabContentText6"].ToString();
placeholder6.Visible = true;
}
}
}
/// <summary>
/// Reloads the control data.
/// </summary>
public override void ReloadData()
{
base.ReloadData();
SetupControl();
}
#endregion
}