ASP.net Control Development Series III

Source: Internet
Author: User
Tags control label

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
{
 
}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.