Next, we will introduce the attribute commonly used by server controls.
VI,ToolboxdataattributeCategory
Purpose: Specify the default tag generated by the custom control when it is dragged from the toolbox to the page.
When a new server control is added, it applies toolboxdataattribute in the control category by default and defines the control in the aspxProgramCode.
<Toolboxdata ("<{0}: tbbutton runat = Server> </{0}: tbbutton>")> _
Public ClassTbbutton
InheritsSystem. Web. UI. webcontrols. Button
EndClass
VII,DefaultpropertyattributeCategory
Purpose: Specify the default attributes of a category.
In the following example, defaultpropertyattribute is applied to the mytextbox category and the text attribute is set as the default attribute.
<Defaultproperty ("Text")> _
Public ClassMytextbox
InheritsWebcontrol
Public PropertyText ()As String
Get
Return Ctype(Me. Viewstate ("Text"),String)
End Get
Set(ByvalValueAs String)
Me. Viewstate ("Text") = Value
End Set
End Property
EndClass
8,DefaulteventattributeCategory
Purpose: Specify the preset events of the control.
In the following example, defaulteventattribute is applied to the mytextbox category and textchanged is set as the default attribute.
<Defaultevent ("Textchanged")> _
Public ClassMytextbox
InheritsWebcontrol
''' <Summary>
'''Textchanged event.
''' </Summary>
Public EventTextchangedAsEventhandler
EndClass
In the design phase, when the mytextbox control on the page is clicked 2, a preset event processing function is generated.
Protected SubMytextbox1_textchanged (ByvalSenderAs Object,ByvalEAsSystem. eventargs)HandlesMytextbox3.textchanged
EndSub
IX,LocalizableattributeCategory
Purpose: specify whether the attribute should be localized.
When localizableattribute is set to true, its attribute values are stored in the resource file. In the future, these resource files can be localized without modifying program code.
<Localizable (True)> _
Public PropertyText ()As String
Get
Return Ctype(Me. Viewstate ("Text"),String)
End Get
Set(ByvalValueAs String)
Me. Viewstate ("Text") = Value
End Set
EndProperty
10,DesignerattributeCategory
Purpose: set the Service category of the control during the design stage.
Specify a service category in the design phase to manage the behavior of the control in the design phase, such as the appearance of the control in the design phase and intelligent TAG content. For example, the tbgridview control in the following example defines the behavior of tbgridviewdesigner to implement the design stage. In the future chapter, we will also introduce how to implement the designer of the control.
<Designer (GetType(Tbgridviewdesigner)> _
Public ClassTbgridview
InheritsGridview
EndClass
XI,EditorattributeCategory
Purpose: Specify the editor for editing attribute values in the Properties window.
For example, the items attribute of The ListBox control. When you edit the items attribute in the Properties window, the items set Attribute Editor is displayed. The following example defines the editor category of the items attribute as tblistitemscollectioneditor. In the future section, we will also introduce how to implement the Attribute Editor.
<Editor (GetType(Tblistitemscollectioneditor ),GetType(System. Drawing. Design. uitypeeditor)> _
Public Overrides Readonly PropertyItems ()AsListitemcollection
Note: This article is also published in "the first it state help tie Ren Competition". If you think this articleArticleIt is helpful to you. Remember to add popularity when you connect to this article ^
Http://ithelp.ithome.com.tw/question/10012060