Title: Label Control for self-implemented server controls
Statement: This post is only a test demo. Therefore, it will not be written too standard or considered for security. for convenience. therefore, we hope to improve it when using it in projects.
Environment
Development Tool: vs.net 2003
Database: SQL Server 2000
Author: endless Wandao
Date: 2006-02-20
Reader requirements: have certain programming experience.
Principle: encapsulate HTML controls.
Using system;
Using system. Web. UI;
Using system. Web. UI. design;
Using system. Web. UI. webcontrols;
Using system. componentmodel;
Using system. componentmodel. design;
Namespace skyendless. mycontrols
{
/** // <Summary>
/// Summary of webcustomcontrol1.
/// </Summary>
[Defaultproperty ("text "),
Toolboxdata ("<{0}: Label runat = Server> </{0}: Label>")]
Public class label: system. Web. UI. webcontrols. webcontrol
{
Private string text;
[Bindable (true ),
Category ("appearance "),
Defaultvalue ("")]
Public String text
{
Get
{
Return text;
}
Set
{
TEXT = value;
}
}
/** // <Summary>
/// Present the control to the specified output parameter.
/// </Summary>
/// <Param name = "output"> HTML writer to be written </param>
Protected override void render (htmltextwriter output)
{
String outputhtml = "<Div name =" + this. uniqueid + ">" + this. Text + "</div> ";
Output. Write (outputhtml );
}
}
}
Note: I will continue to implement several common server controls in the future.
This is just a simple custom control.
You cannot drag a widget to control its size.
Now, you can see that you can drag the label control of the size with the mouse when designing the server control series.