File: D:/HostingSpaces/TDijk1/erp-apps.eu/wwwroot/CMSWebParts/Pux/Layouts/CustomLayout.ascx.cs
using CMS.Helpers;
using CMS.PortalControls;
using CMS.PortalEngine;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class CMSWebParts_Pux_Layouts_CustomLayout : CMSAbstractLayoutWebPart
{
#region "Properties"
/// <summary>
/// Column definition of CSS classes which should be used to render content.
/// Multiple values separated by pipe ("|"), e.g. "col-xs-4|col-xs-3|col-xs-5" will render three columns
/// </summary>
public string ColumnsDefinition
{
get
{
return ValidationHelper.GetString(this.GetValue("ColumnsDefinition"), "");
}
set
{
this.SetValue("ColumnsDefinition", value);
}
}
#endregion
#region "Layout methods"
// for more info see https://docs.kentico.com/display/K9/Developing+layout+web+parts
protected override void PrepareLayout()
{
// Starts building the layout code
StartLayout();
cssStyle.Visible = IsDesign;
// Wraps the layout into a table with additional content if the web part is edited in Design mode
if (IsDesign)
{
Append("<table class=\"LayoutTable\" cellspacing=\"0\" width=\"100%\">");
if (PortalContext.IsDesignMode(this.ViewMode))
{
Append("<tr><td class=\"LayoutHeader\" colspan=\"2\">");
// Adds a header container.
AddHeaderContainer();
Append("</td></tr>");
}
Append("<tr><td>");
}
// Calls the private method that adds the web part zone
InsertZones();
// Closes the Design mode table
if (IsDesign)
{
Append("</td></tr>");
Append("</table>");
}
// Saves the current status of the layout code and ensures that it is rendered on the page
FinishLayout();
}
private void InsertZones()
{
var columns = ColumnsDefinition.Split('|');
int i = 0;
// generate all columns based on column definition
foreach (var column in columns)
{
// opening DIV
Append("<div");
if (!String.IsNullOrEmpty(column))
{
// add CSS class for the column
Append(" class=\"" + (IsDesign ? "pux-ui-margin-top" : String.Empty) + " " + column.Replace("\"", "") + "\"");
}
// Defines the DIV element's id attribute used to identify the zone's envelope in Design mode
if (IsDesign)
{
Append(" id=\"", ShortClientID, "_zoneEnvelope\"");
}
Append(">"); // end opening DIV
// Add web part zone
CMSWebPartZone zone = AddZone(this.ID + "_zone_" + i, this.ID);
Append("</div>"); // closing DIV
i++;
}
}
#endregion
}