Asp.net Web control custom class attributes (experience)

Source: Internet
Author: User

When designing controls, we often need to use our own defined classes as the control attributes,
However, unfortunately, IDE does not know the birth of a new category in advance. Therefore, we need
You can use TypeConverter to convert a custom object into a string and display it to the control.
In the property page of, put the character string in the property page (the color in aspx is also a string, such:
# Eef008) to a custom class.
The following two methods can be used to implement TypeConverter:
1. Apply the TypeConverter class defined by the system to convert custom attribute classes, such
ExpandableObjectConverter.
Ii. Apply your own TypeConverter class to convert custom attribute classes.
The first method is as follows: I have already provided an example in the previous article. We will focus on the second method. First, we will provide a suggestion.
Yes. If you want to use a custom TypeConverter class for conversion, it is best to inherit TypeConverter instead
This class inherits ExpandableObjectConverter and other classes inherited from TypeConverter.
Apply ExpandableObjectConverter to display attributes in a tree structure, and write TypeConverter
Yes, you can use the edit string to change the attribute settings. If you inherit
ExpandableObjectConverter, I found that sometimes when editing subattributes of class attributes, IDE sometimes does not
Update ParentProperty in time (Added policyparentproperty = true to the property of the custom class). Therefore,
It is best not to use the TypeConverter class written by yourself to inherit ExpandableObjectConverter.
You can modify the attributes of a Web control by modifying the sub-attributes of a class attribute or directly modifying the attributes of a string,
But sometimes there are some minor problems that make you feel uncomfortable.
Therefore, we recommend that you either apply ExpandableObjectConverter directly or inherit the property class written by yourself.
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.