开发者

What Types of properties can be set directly in declarative markup (as attributes)?

I understand that whenever you creat开发者_StackOverflowe a property for a user control, you can set the property value through declarative syntax, so you can have something like this:

<uc1:MyControl id="MyControl1" runat="server" Text="Hello" Number="10" Access="ReadWrite" />

These attributes set the value for properties of type:

  • Text is String
  • Number is Integer
  • Access is Enum

I wouldn't be able to set a public property of type "Array" or "Control" in declarative markup. (or can I?)

My question is:

What is the complete list of Types that can be set directly with declarative syntax as attributes in a control?


Ok, after some time with this question without being solved, finally I found the official answer in this article at the MSDN library.

Turns out that those properties that can be persisted as attributes are called Simple Properties and must be a string or a type that easily maps to a string. Here's an extract of the article:

" A simple property is a property whose type is a string or a type that maps easily to a string. A simple property is persisted as an attribute on the control's opening tag without any work on your part. Properties of type String and primitive value types in the .NET Framework class library such as Boolean, Int16, Int32, and Enum are simple properties. "

So I had the list almost complete in my question. Properties that can be set directly with declarative syntax (as atributes) must be of the following types:

  • String
  • Boolean
  • Int16
  • Int32
  • Enum
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜