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?
Edit: Or should I go for a different design like exposing css classes as properties like "HeaderStyle-CssClass" of GridView?
If you're using the Chrome inspector (right click page, inspect element), highlight the line and look to the right. It should show the CSS class and any rules that are used, and a link to the CSS file.
The best way to style a control is to use the style properties defined by the control and to use a style sheet or inline styles to make minor adjustments to individual elements if necessary. To override a style defined by a control's style properties, use the ! important CSS rule in a style sheet or inline styles.
Yes, you have to link the style sheet file (. css) by adding the link tag. You can also simply drag the css file into the html section of the . aspx code right under head tag, that will work too - that will create the link for you.
To select elements with a specific class, write a period (.) character, followed by the name of the class. You can also specify that only specific HTML elements should be affected by a class. To do this, start with the element name, then write the period (.)
Here's what I did:
<link rel="Stylesheet" type="text/css" href="Stylesheet.css" id="style" runat="server" visible="false" />
It fools Visual Studio into thinking you've added a stylesheet to the page but it doesn't get rendered.
Here's an even more concise way to do this with multiple references;
<% if (false) { %> <link rel="Stylesheet" type="text/css" href="Stylesheet.css" /> <script type="text/javascript" src="js/jquery-1.2.6.js" /> <% } %>
As seen in this blog post from Phil Haack.
Add the style on your usercontrol and import css in it.
<%@ Control Language="vb" AutoEventWireup="false" CodeBehind="WCReportCalendar.ascx.vb" Inherits="Intra.WCReportCalender" %> <style type='text/css'> @import url("path of file.css"); // This is how i used jqueryui css @import url("http://code.jquery.com/ui/1.10.0/themes/base/jquery-ui.css"); </style> your html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With