<p>Since there are no header sections for user controls in asp.net, user controls have no way of knowing about stylesheet files. So css classes in the user controls are not recognized by visual studio and produces warnings. How can I make a user control know that it will relate to a css class, so if it is warning me about a non-existing css class, it means that the class really do not exist?</p>

<p>Edit: Or should I go for a different design like exposing css classes as properties like "HeaderStyle-CssClass" of GridView?</p>

[{'answer_id': 34432, 'author': 'Rob Cooper', 'author_id': 832, 'author_profile': 'https://Stackoverflow.com/users/832', 'pm_score': 0, 'selected': False, 'text': '<p>If you are creating composite UserControl, then you can set the <a href="http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.webcontrol.cssclass.aspx" rel="nofollow noreferrer">CSSClass</a> property on the child controls..</p>\n\n<p>If not, then you need to expose properties that are either of the <a href="http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.webcontrol.cssclass.aspx" rel="nofollow noreferrer">Style</a> type, or (as I often do) string properties that apply CSS at the render type (i.e. take them properties and add a <em>style</em> attribute to the HTML tags when rendering).</p>\n'}, {'answer_id': 34502, 'author': 'Adam Lassek', 'author_id': 1249, 'author_profile': 'https://Stackoverflow.com/users/1249', 'pm_score': 7, 'selected': True, 'text': '<p>Here\'s what I did:</p>\n\n<pre><code>&lt;link rel="Stylesheet" type="text/css" href="Stylesheet.css" id="style" runat="server" visible="false" /&gt;\n</code></pre>\n\n<p>It fools Visual Studio into thinking you\'ve added a stylesheet to the page but it doesn\'t get rendered.</p>\n\n<hr>\n\n<p>Here\'s an even more concise way to do this with multiple references;</p>\n\n<pre><code>&lt;% if (false) { %&gt;\n    &lt;link rel="Stylesheet" type="text/css" href="Stylesheet.css" /&gt;\n    &lt;script type="text/javascript" src="js/jquery-1.2.6.js" /&gt;\n&lt;% } %&gt;\n</code></pre>\n\n<p>As seen in <a href="http://haacked.com/archive/2008/11/21/combining-jquery-form-validation-and-ajax-submission-with-asp.net.aspx" rel="noreferrer">this blog post</a> from Phil Haack.</p>\n'}, {'answer_id': 9953418, 'author': 'Kirtish Srivastava', 'author_id': 1304634, 'author_profile': 'https://Stackoverflow.com/users/1304634', 'pm_score': -1, 'selected': False, 'text': '<p>You Can use <code>CSS</code> direct in <code>userControl</code>.</p>\n\n<p>Use this in <code>UserControl</code>:</p>\n\n<pre><code> &lt;head&gt;\n    &lt;title&gt;&lt;/title&gt; \n    &lt;style type="text/css"&gt;\n      .wrapper {\n          margin: 0 auto -142px; \n         /* the bottom margin is the negative value of the footer\'s height */ \n       }\n    &lt;/style&gt;\n &lt;/head&gt;\n</code></pre>\n\n<p>This will work.</p>\n'}, {'answer_id': 14774992, 'author': 'Abdul Saboor', 'author_id': 1176903, 'author_profile': 'https://Stackoverflow.com/users/1176903', 'pm_score': 2, 'selected': False, 'text': '<p>Add the style on your usercontrol and import css in it.</p>\n\n<pre><code> &lt;%@ Control Language="vb" AutoEventWireup="false" CodeBehind="WCReportCalendar.ascx.vb"\nInherits="Intra.WCReportCalender" %&gt;\n &lt;style type=\'text/css\'&gt;    \n      @import url("path of file.css");\n       // This is how i used jqueryui css\n      @import url("http://code.jquery.com/ui/1.10.0/themes/base/jquery-ui.css");               \n\n &lt;/style&gt;\n\n your html \n</code></pre>\n'}]
['https://Stackoverflow.com/questions/34390', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/31505/']