Click here to Skip to main content
15,920,217 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:

I have createa a user control and apply a style shet on it as under:

<%@ Control Language="C#"%>
<link href="StyleSheet.css" rel="stylesheet" type="text/css"/>
<div class="a1">
<asp:CheckBox ID="CheckBox1" runat="server"/>

When i add this user control on my web forms style shet will not apply. I don't want to add reference of stylesheet file in my page

Pls. help me.

Updated 18-Oct-11 1:47am

I would suggest that the path to the style sheet is not being resolved correctly.

The href needs to be relative to the page that is hosting the user control and not the user control itself.

<link href="~StyleSheet.css" rel="stylesheet" type="text/css" />
Share this answer
I think You create a control taht will be use at different palaces.
and You want to provide styles to thje control.
If you take
<link href="StyleSheet.css" rel="stylesheet" type="text/css" />

Then you would definitly need styleSheet.css.
So you can use style tag to provide foramatting to your control as
<pre><div style="width:20%; Height=100px">
<asp:CheckBox ID="CheckBox1" runat="server"/>

Share this answer
Muralikrishna8811 18-Oct-11 8:22am    
in design page (.aspx), drag and drop this style sheet. It will apper like below..
Ex: your style sheet in Style folder in application and Style sheet name is overview.css then..

How to apply

<asp:textbox id="txtName" runat="server" cssclass="txtStyle" xmlns:asp="#unknown">
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900