Property Full Contact (i)
The article in this series has several Sham, encouraged a few words, so the vigor and sufficient, this is not, this article will come out quickly,:
Hope to continue to be encouraged and corrected.
This time we'll explore all aspects of the attribute design in control development, Attributes are the most basic syntax for various. NET languages, but the control as a release to the programmer two development, the powerful and flexible use of a good property design, so I think the property design is the first in control development to lay the fort.
First, let's take a look at the HTML-style code in the. aspx file:
<asp:DropDownList id="DropDownList1" runat="server" Font-Bold="True">
<asp:ListItem Value="1">1</asp:ListItem>
<asp:ListItem Value="2">2</asp:ListItem>
</asp:DropDownList>
This code has been written countless times, but now we have to analyze this code from another perspective:
The DropDownList control, when interacting with the user, does not represent its attributes in a single brain, but is divided into the following situations:
1. Like ID, Runat, font-bold These, put in <> tag;
Unlike other 2.font-bold, it has a short horizontal split into two parts, which is not Font-bold is the name of a property, but rather it is a child property and is the Bold property of the Font property (font Class). The corresponding. cs file is written as: Font.Bold;
The 3.ListItem was placed in the middle of a pair of DropDownList <> marks, not a marker, and 1 and 2 were placed in the middle of the listitem.
Let's take a look at how these kinds of attribute recording methods are implemented separately.
There is an attribute to do this event PersistenceMode (System.Web.UI.PersistenceModeAttribute).
It has the following several values to choose from:
Attribute (default) property is stored in the label of the control;
The Encodedinnerdefaultproperty property is encoded HTML, which is stored in the middle of the control label pair, and the above ListItem saves the Text property (1, 2);
[PersistenceMode(PersistenceMode.EnCodedInnerDefaultProperty)]
public string Text
{
}