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

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

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

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

Pls. help me.

Thanks
.
Posted
Updated 18-Oct-11 1:47am
v2

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.

e.g
HTML
<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
C#
<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
ASP.NET
<pre><div style="width:20%; Height=100px">
<asp:CheckBox ID="CheckBox1" runat="server"/>
</div>

 
Share this answer
 
Comments
Muralikrishna8811 18-Oct-11 8:22am    
Nice
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