Welcome 微信登录

首页 / 网页编程 / ASP.NET / ASP.NET控件开发基础(5)

ASP.NET控件开发基础(5)2011-01-08Clingingboy我们根据属性的不同表现形式,把其区分为简单属性和复杂属性

下面来看下属性的表现形式

简单属性表现形式如下,大家都很熟悉

<asp:TextBox ID="TextBox1" Text="textbox控件" runat="server"></asp:TextBox>

属性中含有子属性,称之为复杂对象,如Font属性

复杂属性的表现形式如下,

(1)连字符的表现形式

<asp:TextBox ID="TextBox1" Text="textbox控件" runat="server" Font-Bold="True"></asp:TextBox>

(2)内镶属性的表现形式,如定义样式

<asp:DataList ID="DataList1" runat="server">
<SelectedItemStyle />
<EditItemStyle />
</asp:DataList>

(3)内镶集合属性的表现形式,如DropDownList (先不介绍,大家可看MSDN) <asp:DropDownList ID="DropDownList1" runat="server">

<asp:ListItem>x</asp:ListItem>
<asp:ListItem>xx</asp:ListItem>
<asp:ListItem>xxx</asp:ListItem>
</asp:DropDownList>

下面得好好看

1,复杂属性基本使用方法

请看我是怎么做的,关于下面看到了一些元数据,如果你不熟悉,请参考MSDN.

下面一段代码记录一个custom的信息.

1.1 定义枚举

using System;

namespace CustomComponents
{
/**//// <summary>
/// 职业
/// </summary>
public enum Metier
{
教师,程序员,作家
}
}