哪些类型的属性可以直接在声明性标记中设置(作为属性)?
据我所知,每当您为用户控件创建属性时,都可以通过声明性语法设置属性值,因此您可以具有如下内容:
<uc1:MyControl id="MyControl1" runat="server" Text="Hello" Number="10" Access="ReadWrite" />
这些属性设置类型属性的值:
- 文本是字符串
- 数字是整数
- 访问是枚举
我无法在声明性标记中设置“Array”或“Control”类型的公共属性。 (或者我可以吗?)
我的问题是:
可以使用声明性语法直接设置为控件中的属性的类型的完整列表是什么?
I understand that whenever you create 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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好的,经过一段时间这个问题没有得到解决,最后我在这个 MSDN 库中的文章。
事实证明,那些可以作为属性持久化的属性称为简单属性,并且必须是字符串或可以轻松映射到字符串的类型。以下是文章的摘录:
所以我的问题中的列表几乎完整。可以使用声明性语法(作为属性)直接设置的属性必须是以下类型:
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:
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: