You can use the content box in a web page like:
Code:
using System.Web.UI.WebControls; namespace CarverPainting { public class ContentBox : Panel { public string CssClassBody { get { return base.CssClass; } set { base.CssClass = value; } } public override string CssClass { get { return ViewState["CssClassMain"] == null ? string.Empty : ViewState["CssClassMain"].ToString(); } set { ViewState["CssClassMain"] = value; } } public string CssClassTitle { get { return ViewState["CssClassTitle"] == null ? string.Empty : ViewState["CssClassTitle"].ToString(); } set { ViewState["CssClassTitle"] = value; } } public string Title { get { return ViewState["Title"] == null ? string.Empty : ViewState["Title"].ToString(); } set { ViewState["Title"] = value; } } protected override void Render(System.Web.UIHtmlTextWriter writer) { bool hasClass = !string.IsNullOrWhiteSpace(CssClass); bool hasClassTitle = !string.IsNullOrWhiteSpace(CssClassTitle); bool hasClassBody = !string.IsNullOrWhiteSpace(CssClassBody); // contentbox class writer.Write("<div{0}>", hasClass ? string.Format(" class=\"{0}\"", CssClass) : string.Empty); if (!string.IsNullOrWhiteSpace(Title)) { writer.Write("<div{0}>{1}</div>", hasClassTitle ? string.Format(" class=\"{0}\"", CssClassTitle) : string.Empty, Title); } base.Render(writer); // contentbox class writer.Write("</div>"); } } }
No comments:
Post a Comment