Control this control mainly resolves the client-side validation script in the custom composite control.
Using System;
Using System.Web;
Using System.Web.UI;
Using System.Web.UI.WebControls;
Using System.ComponentModel;
Namespace Only.compositioncontrols
{
<summary>
Create by Liyi.
Date:2004-10-10
</summary>
[Defaultproperty ("value"), ValidationPropertyAttribute ("value"), ToolBoxData ("<{0}:literaltextbox runat=server ></{0}:LiteralTextBox> ")]
public class Literaltextbox:control,inamingcontainer
{
The following script is used to enter page numbers from a text box
[DefaultValue ("Text:"), Category ("Custom")]
public string Text
{
Get
{
This. EnsureChildControls ();
Return ((LiteralControl) controls[0]). Text;
}
Set
{
This. EnsureChildControls ();
((LiteralControl) controls[0]). Text = value;
}
}
[DefaultValue ("Value"), Category ("Custom")]
public string Value
{
Get
{
This. EnsureChildControls ();
Return ((TextBox) controls[1]). Text;
}
Set
{
This. EnsureChildControls ();
((TextBox) controls[1]). Text = value;
}
}
[DefaultValue (""), Category ("Custom")]
Public Unit Width
{
Get
{
This. EnsureChildControls ();
Return ((TextBox) controls[1]). Width;
}
Set
{
This. EnsureChildControls ();
((TextBox) controls[1]). Width = value;
}
}
[DefaultValue (TextBoxMode.SingleLine), Category ("Custom")]
Public TextBoxMode TextMode
{
Get
{
This. EnsureChildControls ();
Return ((TextBox) controls[1]). TextMode;
}
Set
{
This. EnsureChildControls ();
((TextBox) controls[1]). TextMode = value;
}
}
[DefaultValue (Borderstyle.notset), Category ("Custom")]
Public BorderStyle BorderStyle
{
Get
{
This. EnsureChildControls ();
Return ((TextBox) controls[1]). BorderStyle;
}
Set
{
This. EnsureChildControls ();
((TextBox) controls[1]). BorderStyle = value;
}
}
[DefaultValue (""), Category ("Custom")]
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);
}
}
}