截图说明:
Code
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
[assembly: TagPrefix("HBControlLibrary", "GroupBox")]
namespace LuisControls
{
[DefaultProperty("Text")]
[ToolboxData("<{0}:GroupBox runat=server></{0}:GroupBox>")]
public class GroupBox : Panel, INamingContainer
{
#region 属性
[Category("GroupBox")]
[Bindable(true)]
[Description("GroupBox的高")]
public override Unit Height
{
get { return base.Height; }
set { base.Height = value; }
}
[Category("GroupBox")]
[Bindable(true)]
[Description("GroupBox 的宽")]
public override Unit Width
{
get { return base.Width; }
set { base.Width = value; }
}
private string _fieldsetstyle = "border: green 1px solid; padding:10px; margin-bottom: 8px; text-align: left";
[Category("外观")]
[Bindable(true)]
[Description("Fieldset 样式")]
public string FieldsetStyle
{
get { return _fieldsetstyle; }
set { _fieldsetstyle = value; }
}
private string _fieldsetstyleclassname = "groupboxfield";
[Category("外观")]
[Bindable(true)]
[Description("Fieldset 样式名")]
public string FieldsetStyleClassName
{
get { return _fieldsetstyleclassname; }
set { _fieldsetstyleclassname = value; }
}
private string _legendstyle = "background:url(../images/users.jpg) no-repeat 6px 35% ;border: green 0px solid;padding-left: 60px; font-weight: bold; line-height: 45px";
[Category("外观")]
[Bindable(true)]
[Description("Legend 样式")]
public string LegendStyle
{
get { return _legendstyle; }
set { _legendstyle = value; }
}
private string _legendstyleclassname = "groupboxlegend";
[Category("外观")]
[Bindable(true)]
[Description("Legend 样式名")]
public string LegendStyleClassName
{
get { return _legendstyleclassname; }
set { _legendstyleclassname = value; }
}
private bool _writecsstofile = false;
[Category("外观")]
[Bindable(true)]
[Description("Legend 是否允许外观写在css文件中")]
public bool WriteCssToFile
{
get { return _writecsstofile; }
set { _writecsstofile = value; }
}
[Category("GroupBox")]
[Bindable(true)]
[Description("GroupBox 标题")]
public string GroupTitle
{
get
{
String s = (String)ViewState["GroupTitle"];
return ((s == null) ? String.Empty : s);
}
set
{
ViewState["GroupTitle"] = value;
}
}
#region 废弃不用属性
[Bindable(false), Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
public override string GroupingText
{
get
{
return "";
}
}
[Bindable(false), Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
public override System.Drawing.Color BackColor
{
get
{
return base.BackColor;
}
set
{
base.BackColor = value;
}
}
[Bindable(false), Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
public override System.Drawing.Color BorderColor
{
get
{
return base.BorderColor;
}
set
{
base.BorderColor = value;
}
}
[Bindable(false), Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
public override Unit BorderWidth
{
get
{
return base.BorderWidth;
}
set
{
base.BorderWidth = value;
}
}
[Bindable(false), Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
public override BorderStyle BorderStyle
{
get
{
return base.BorderStyle;
}
set
{
base.BorderStyle = value;
}
}
[Bindable(false), Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
public override FontInfo Font
{
get
{
return base.Font;
}
}
[Bindable(false), Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
public override System.Drawing.Color ForeColor
{
get
{
return base.ForeColor;
}
set
{
base.ForeColor = value;
}
}
[Bindable(false), Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
public override ContentDirection Direction
{
get
{
return base.Direction;
}
set
{
base.Direction = value;
}
}
[Bindable(false), Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
public override HorizontalAlign HorizontalAlign
{
get
{
return base.HorizontalAlign;
}
set
{
base.HorizontalAlign = value;
}
}
[Bindable(false), Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
public override ScrollBars ScrollBars
{
get
{
return base.ScrollBars;
}
set
{
base.ScrollBars = value;
}
}
#endregion
#endregion
protected override void RenderContents(HtmlTextWriter writer)
{
//<fieldset style="border: green 1px solid; padding: 4px 30px 10px 30px; margin-bottom: 8px; text-align: left">
// <legend style="background:url(../images/users.jpg) no-repeat 6px 35% ;border: green 1px solid;PADDING-LEFT: 60px; FONT-WEIGHT: bold; LINE-HEIGHT: 45px">
// aaa
// </legend>
//sdfgsdfgsdfg
//</fieldset>
if (!WriteCssToFile)
{
writer.AddAttribute(HtmlTextWriterAttribute.Style, _fieldsetstyle);
}
else
{
writer.AddAttribute(HtmlTextWriterAttribute.Class, _fieldsetstyleclassname);
}
if (!Width.IsEmpty)
{
writer.AddStyleAttribute(HtmlTextWriterStyle.Width, Width.ToString());
}
if (!Height.IsEmpty)
{
writer.AddStyleAttribute(HtmlTextWriterStyle.Height, Height.ToString());
}
writer.RenderBeginTag(HtmlTextWriterTag.Fieldset);
if (!WriteCssToFile)
{
writer.AddAttribute(HtmlTextWriterAttribute.Style, _legendstyle);
}
else
{
writer.AddAttribute(HtmlTextWriterAttribute.Class,_legendstyleclassname);
}
GroupTitle = GroupTitle;
writer.RenderBeginTag(HtmlTextWriterTag.Legend);
writer.Write(GroupTitle);
writer.RenderEndTag();
base.RenderContents(writer);
writer.RenderEndTag();
}
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
[assembly: TagPrefix("HBControlLibrary", "GroupBox")]
namespace LuisControls
{
[DefaultProperty("Text")]
[ToolboxData("<{0}:GroupBox runat=server></{0}:GroupBox>")]
public class GroupBox : Panel, INamingContainer
{
#region 属性
[Category("GroupBox")]
[Bindable(true)]
[Description("GroupBox的高")]
public override Unit Height
{
get { return base.Height; }
set { base.Height = value; }
}
[Category("GroupBox")]
[Bindable(true)]
[Description("GroupBox 的宽")]
public override Unit Width
{
get { return base.Width; }
set { base.Width = value; }
}
private string _fieldsetstyle = "border: green 1px solid; padding:10px; margin-bottom: 8px; text-align: left";
[Category("外观")]
[Bindable(true)]
[Description("Fieldset 样式")]
public string FieldsetStyle
{
get { return _fieldsetstyle; }
set { _fieldsetstyle = value; }
}
private string _fieldsetstyleclassname = "groupboxfield";
[Category("外观")]
[Bindable(true)]
[Description("Fieldset 样式名")]
public string FieldsetStyleClassName
{
get { return _fieldsetstyleclassname; }
set { _fieldsetstyleclassname = value; }
}
private string _legendstyle = "background:url(../images/users.jpg) no-repeat 6px 35% ;border: green 0px solid;padding-left: 60px; font-weight: bold; line-height: 45px";
[Category("外观")]
[Bindable(true)]
[Description("Legend 样式")]
public string LegendStyle
{
get { return _legendstyle; }
set { _legendstyle = value; }
}
private string _legendstyleclassname = "groupboxlegend";
[Category("外观")]
[Bindable(true)]
[Description("Legend 样式名")]
public string LegendStyleClassName
{
get { return _legendstyleclassname; }
set { _legendstyleclassname = value; }
}
private bool _writecsstofile = false;
[Category("外观")]
[Bindable(true)]
[Description("Legend 是否允许外观写在css文件中")]
public bool WriteCssToFile
{
get { return _writecsstofile; }
set { _writecsstofile = value; }
}
[Category("GroupBox")]
[Bindable(true)]
[Description("GroupBox 标题")]
public string GroupTitle
{
get
{
String s = (String)ViewState["GroupTitle"];
return ((s == null) ? String.Empty : s);
}
set
{
ViewState["GroupTitle"] = value;
}
}
#region 废弃不用属性
[Bindable(false), Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
public override string GroupingText
{
get
{
return "";
}
}
[Bindable(false), Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
public override System.Drawing.Color BackColor
{
get
{
return base.BackColor;
}
set
{
base.BackColor = value;
}
}
[Bindable(false), Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
public override System.Drawing.Color BorderColor
{
get
{
return base.BorderColor;
}
set
{
base.BorderColor = value;
}
}
[Bindable(false), Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
public override Unit BorderWidth
{
get
{
return base.BorderWidth;
}
set
{
base.BorderWidth = value;
}
}
[Bindable(false), Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
public override BorderStyle BorderStyle
{
get
{
return base.BorderStyle;
}
set
{
base.BorderStyle = value;
}
}
[Bindable(false), Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
public override FontInfo Font
{
get
{
return base.Font;
}
}
[Bindable(false), Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
public override System.Drawing.Color ForeColor
{
get
{
return base.ForeColor;
}
set
{
base.ForeColor = value;
}
}
[Bindable(false), Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
public override ContentDirection Direction
{
get
{
return base.Direction;
}
set
{
base.Direction = value;
}
}
[Bindable(false), Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
public override HorizontalAlign HorizontalAlign
{
get
{
return base.HorizontalAlign;
}
set
{
base.HorizontalAlign = value;
}
}
[Bindable(false), Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
public override ScrollBars ScrollBars
{
get
{
return base.ScrollBars;
}
set
{
base.ScrollBars = value;
}
}
#endregion
#endregion
protected override void RenderContents(HtmlTextWriter writer)
{
//<fieldset style="border: green 1px solid; padding: 4px 30px 10px 30px; margin-bottom: 8px; text-align: left">
// <legend style="background:url(../images/users.jpg) no-repeat 6px 35% ;border: green 1px solid;PADDING-LEFT: 60px; FONT-WEIGHT: bold; LINE-HEIGHT: 45px">
// aaa
// </legend>
//sdfgsdfgsdfg
//</fieldset>
if (!WriteCssToFile)
{
writer.AddAttribute(HtmlTextWriterAttribute.Style, _fieldsetstyle);
}
else
{
writer.AddAttribute(HtmlTextWriterAttribute.Class, _fieldsetstyleclassname);
}
if (!Width.IsEmpty)
{
writer.AddStyleAttribute(HtmlTextWriterStyle.Width, Width.ToString());
}
if (!Height.IsEmpty)
{
writer.AddStyleAttribute(HtmlTextWriterStyle.Height, Height.ToString());
}
writer.RenderBeginTag(HtmlTextWriterTag.Fieldset);
if (!WriteCssToFile)
{
writer.AddAttribute(HtmlTextWriterAttribute.Style, _legendstyle);
}
else
{
writer.AddAttribute(HtmlTextWriterAttribute.Class,_legendstyleclassname);
}
GroupTitle = GroupTitle;
writer.RenderBeginTag(HtmlTextWriterTag.Legend);
writer.Write(GroupTitle);
writer.RenderEndTag();
base.RenderContents(writer);
writer.RenderEndTag();
}
}
}
转载无需注明出处,多多交流 ,欢迎访问我的博客:http://www.cnblogs.com/niuniu