System. Web. UI. webcontrols. webcontrol class
Main attributes:
Attribute |
Type |
Description |
Controls |
Controlscollection |
Child widget |
Controlstyle |
Style |
Style |
Controlstylecreated |
Bool |
Returns a value indicating whether a style object is created for controlstyle. |
Enabled |
Bool |
|
Tagkey |
Htmltextwritertag |
Obtain the system. Web. UI. htmltextwritertag value corresponding to the control. |
Main Methods:
Protected virtual void addatrributetorender (htmltextwrter writer) Design Style
Protected override void render (htmltextwriter writer) overrides render
Protected virtual void rendercontrols (htmltextwriter writer) displays the control content.
Public virtrual void renderbegintag (htmltextwrtier witer)
Public virtrual void renderendtag (htmltextwrtier witer)
Public void applystyle (Style S) copies the User-Defined style to the control. If there is overlap, rewrite the control style
Publie void mergestyle (Style S) copies the specified style to the control. If there is overlap, the existing style elements of the control are not rewritten.
Public irtualstylecreatecontrolstyle () webcontrol class internal Style
Using System;
Using System. Collections. Generic;
Using System. text;
Using System. componentmodel;
Using System. Web. UI;
Namespace Usercontrols
{
[
Defaultproperty ( " Text " ),
Toolboxdata ( " <{0}: webcustomercontrol runat = Server> </(0): webcustomercontrol> " )
]
Public Class Userrendertest2: system. Web. UI. webcontrols. webcontrol
{
Private String Text = "" ;
Private String Href = "" ;
Public Userrendertest2 (): Base (System. Web. UI. htmltextwritertag. Div)
{
}
[
Description ( " To show text " ),
Bindable ( True ),
Category ( " Appearance " ),
Defaultvalue ( " " )
]
Public String Text
{
Get {ReturnText ;}
Set {Text=Value ;}
}
[
Description ( " To show href " ),
Bindable ( True ),
Category ( " Appearance " ),
Defaultvalue ( " " )
]
Public String Href
{
Get {ReturnHref ;}
Set {Href=Value ;}
}
Protected Override Void Addattributestorender (system. Web. UI. htmltextwriter writer)
{
Writer. addstyleattribute (system. Web. UI. htmltextwriterstyle. borderstyle,"#999 1px solid");
Base. Addattributestorender (writer );
}
Public Override Void Rendercontrol (system. Web. UI. htmltextwriter writer)
{
Writer. addattribute ( " Onmouseover " , " This.style.css text = 'color: red' " );
Writer. addattribute (system. Web. UI. htmltextwriterattribute. href, href );
Writer. renderbegintag (system. Web. UI. htmltextwritertag. );
Writer. Write (text );
Writer. renderendtag ();
Base . Rendercontrol (writer );
}
}
}