In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
Today, I will talk to you about the form of expression of ASP.NET attributes, which may not be well understood by many people. in order to make you understand better, the editor has summarized the following content for you. I hope you can get something according to this article.
According to the different forms of expression of ASP.NET attributes, we divide them into simple attributes and complex attributes.
Let's take a look at the representation of ASP.NET attributes.
Simple attributes are represented as follows. We are all familiar with attributes that contain sub-attributes, which are called complex objects, such as Font attributes.
(1) the expression of hyphens
(2) the representation of inlaid attributes, such as defining styles.
(3) the representation of embedded collection properties, such as DropDownList
Basic usage of complex attributes
Please see how I do it, about the following to see some metadata, if you are not familiar with, please refer to MSDN.
The following code records a custom message.
1. Define enumeration
UsingSystem; namespaceCustomComponents {/ * * / Professional / publicenumMetier {teacher, programmer, writer}}
two。 Define complex attributes
UsingSystem; usingSystem.ComponentModel; namespaceCustomComponents {/ * * / address Collection / publicclassAddress {privateStringstreet=null; privateStringcity=null; privateStringstate=null; privateStringzip=null; publicStringStreet {get {returnstreet;} set {street=value;}} publicStringCity {get {returncity;} set {city=value;}} publicStringState {get {returnstate;} set {state=value;} publicStringZip {get {returnzip } set {zip=value;}
3. Render control
4. Define controls on the ASP.NET page
Open the background code, enter the following code to check the properties, and find that the properties exist, such as the following figure, and then open the view, and find that the control can display the properties, but cannot recognize the properties as valid properties and cannot find them in the source view.
5. Solve the problem that 4 cannot display valid properties, (in fact, the above tests have already implemented complex properties).
Solution: add a metadata to the CustomAddress in the Custom class, as follows
[Description ("address set")] [DesignerSerializationVisibility (DesignerSerializationVisibility.Content)] publicAddressCustomAddress {get {returnaddress;}}
6. Achieve CustomAddress attribute folding effect
Solution: add a metadata to the Address class, as follows
[TypeConverter (typeof (ExpandableObjectConverter))] publicclassAddress {.} after reading the above, do you have any further understanding of the representation of the ASP.NET attribute? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.