asp.net Web Control custom class properties (experience)

Source: Internet
Author: User
When designing a control, we often need to use our own defined classes as properties of the control.
Unfortunately, however, the IDE does not know in advance the birth of the new category, so we need
There are typeconverter to convert the objects you define to a string display to the control
Property page, the string in the property page (the color in ASPX is also a string, such as:
#eef008) into the custom class.
The TypeConverter implementation steps can be in the following two ways:
One: Apply the system-defined TypeConverter class to the custom attribute class, such as applying
Expandableobjectconverter and so on.
Second: Apply your own defined TypeConverter class, make a conversion to the custom attribute class.
The first way that I have in the previous article has been examples where we focus on the second way, first of all a suggestion
Yes, if you want to use a custom TypeConverter class to do the conversion, this class is best to inherit TypeConverter, not
Inherit Expandableobjectconverter, and so on, from the TypeConverter inherited class.
Applying Expandableobjectconverter allows attributes to be displayed in a tree structure, while the TypeConverter is written by itself
Is that you can use the edit string to change the property settings if you inherit the TypeConverter in your own definition
Expandableobjectconverter, I've found that sometimes when you edit a child property of a class attribute, the IDE sometimes does not
Timely update Parentproperty (the attributes of the custom class have been added notifyparentproperty=true), so
It's best not to inherit Expandableobjectconverter with the TypeConverter class you write, though
You can modify the property values of a Web control by modifying the child properties of the Class property, or you can edit the string to modify the property directly.
But sometimes there are small problems that make you feel uncomfortable.
Therefore, it is recommended to either directly apply the Expandableobjectconverter, or write the property class to inherit
TypeConverter, do not inherit expandableobjectconverter.
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.