سؤال

What is the difference between the two methods of setting the css class on web control? How they are synchronized? If I add class to CssClass and Attributes["class"], how it will be rendered?

هل كانت مفيدة؟

المحلول

They both will be rendered the same.

As a class="myClass" in html.

The property CssClass, if set, will take precedence and overwrite the Attributes["class"].

نصائح أخرى

But Keep in mind: if you want to check if your WebControl has "myClass" assigned, you have to look in CssClass AND in the AttributeCollection. (and you have to check with contains because there can be more CssClasses in the string.)

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top