<p>I am in the process of beginning work on several ASP.NET custom controls. I was wondering if I could get some input on your guys/girls thoughts on how you apply styling to your controls.</p>
<p>I would rather push it so CSS, so for the few controls I have done in the past, I have simply stuck a string property which allows you so type in the string which in then slung in a &quot;<em>style</em>&quot; attribute when rendering. I know I could also use the &quot;<strong>CSSClass</strong>&quot; property and apply the &quot;<em>class</em>&quot; attribute.</p>
<p>I have not done much in the way of creating a &quot;proper&quot; <strong>Style</strong> property (in which you actually save the style object, and use the designer to specify its values). This to me seems like a lot of work, and TBH, I hate the Style editor UI and would much rather type in the CSS/class name to apply..</p>
<h2>What are your thoughts on this?</h2>
<hr />
<p><strong>Note:</strong> This is kind of subjective - so to be clear:</p>
<p><strong>The accepted answer will be the one that:</strong></p>
<ul>
<li>Offers the pro's and con's of the various approaches.</li>
<li>Opinions are welcome, but a good answer should be constructive.</li>
<li>Backs it up with some real-world knowledge/experience.</li>
</ul>
<p>There is <strong>nothing</strong> wrong <em>with</em> subjectivity. There <strong>is a problem</strong> with people <em>being</em> subjective and not thinking, being constructive or actually providing some insight and experience.</p>
<p><strong>&gt;&gt;DO NOT&lt;&lt;</strong> tag this as &quot;subjective&quot; - that tag is a waste of time. &quot;subjective&quot; is not a technology or a category that people will look for. Fix the question rather than brush it off.</p>

[{'answer_id': 70422, 'author': 'Martin', 'author_id': 11481, 'author_profile': 'https://Stackoverflow.com/users/11481', 'pm_score': 3, 'selected': True, 'text': "<p>It would depend on how the custom controls are being used - A commercial, re-distributable control should be compliant with the VS IDE, and behave the way users expect it to when they implement the control.</p>\n\n<p>On the other hand there is no point in wasting a lot of time to get styling to work if you or your team are the only ones to use the control, so long as it's styling works in a sane way.</p>\n\n<p>Most of the custom controls I have implemented use a property to define the controls look and feel or just expose the controls' members own CSSClass properties.</p>\n\n<p>The argument comes down to consistency vs. time - any element should use consistent styling mechanisms, if strapped for time, use a string method if not, implement a more complex / IDE friendly mechanism.</p>\n"}, {'answer_id': 70439, 'author': 'Jon Limjap', 'author_id': 372, 'author_profile': 'https://Stackoverflow.com/users/372', 'pm_score': 2, 'selected': False, 'text': '<p>I think you should consider your "target market" for the custom control, e.g., the people who will use it.</p>\n\n<p>If it\'s an internal custom control, you can pretty much mandate the use of one or the other: if it\'s internal to the company you will have the ability to enforce its consistency.</p>\n\n<p>If it\'s meant for commercial consumption, however, it is required that you give an option to provide a way to use either style or class. Case in point: the <a href="http://msdn.microsoft.com/en-us/library/e468hxky.aspx" rel="nofollow noreferrer">ASP.NET site navigation controls</a>, e.g., SiteMapPath, Menu, Treeview. They have a bunch of properties exposed to allow either styles, classes, or a combination of both to each aspect of the controls\' appearance.</p>\n'}]
['https://Stackoverflow.com/questions/70361', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/832/']