繁体中文
设为首页
加入收藏
当前位置:ASP技术首页 >> ASP基础 >> Literal控件与TextBox控件结合的自定义复合控件

Literal控件与TextBox控件结合的自定义复合控件

2006-07-15 08:00:00  作者:  来源:互联网  浏览次数:0  文字大小:【】【】【
简介:本控件主要解决了自定义复合控件中,客户端验证脚本。 using System; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.ComponentModel; namespace Only.CompositionCont...
关键字:控件 TextBox Literal

本控件主要解决了自定义复合控件中,客户端验证脚本。

using System;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.ComponentModel;

namespace Only.CompositionControls

{

///

/// Create By liyi。

/// Date:2004-10-10

///

[DefaultProperty("Value"),ValidationPropertyAttribute("Value"),ToolboxData("<{0}:LiteralTextBox runat=server>")]

public class LiteralTextBox:Control,INamingContainer

{

//以下脚本用于从文本框输入页码

[DefaultValue("Text:"),Category("自定义")]

public string Text

{

get

{

this.EnsureChildControls();

return ((LiteralControl)Controls[0]).Text;

}

set

{

this.EnsureChildControls();

((LiteralControl)Controls[0]).Text = value;

}

}

[DefaultValue("Value"),Category("自定义")]

public string Value

{

get

{

this.EnsureChildControls();

return ((TextBox)Controls[1]).Text;

}

set

{

this.EnsureChildControls();

((TextBox)Controls[1]).Text = value;

}

}

[DefaultValue(""),Category("自定义")]

public Unit Width

{

get

{

this.EnsureChildControls();

return ((TextBox)Controls[1]).Width;

}

set

{

this.EnsureChildControls();

((TextBox)Controls[1]).Width = value;

}

}

[DefaultValue(TextBoxMode.SingleLine),Category("自定义")]

public TextBoxMode TextMode

{

get

{

this.EnsureChildControls();

return ((TextBox)Controls[1]).TextMode;

}

set

{

this.EnsureChildControls();

((TextBox)Controls[1]).TextMode = value;

}

}

[DefaultValue(BorderStyle.NotSet),Category("自定义")]

public BorderStyle BorderStyle

{

get

{

this.EnsureChildControls();

return ((TextBox)Controls[1]).BorderStyle;

}

set

{

this.EnsureChildControls();

((TextBox)Controls[1]).BorderStyle = value;

}

}

[DefaultValue(""),Category("自定义")]

public Unit BorderWidth

{

get

{

this.EnsureChildControls();

return ((TextBox)Controls[1]).BorderWidth;

}

set

{

this.EnsureChildControls();

((TextBox)Controls[1]).BorderWidth = value;

}

}

protected override void CreateChildControls()

{

this.Controls.Add(new LiteralControl("Text:"));

TextBox box = new TextBox();

box.Text = "Value";

box.ID = "Only";

this.Controls.Add(box);

}

}

}

责任编辑:admin
相关文章