Reputation: 83
I have createa a user control and apply a style shet.
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 .
Upvotes: 1
Views: 3299
Reputation: 8606
Generally under in web.config you need to
<pages theme="skinfile" styleSheetTheme="Default">
So that would be available throughout the application.
Upvotes: 0
Reputation: 14460
Try this way
<link rel="Stylesheet" type="text/css" href="<%=ResolveUrl("~/yourpath.css") %>" />
Hope this helps
Upvotes: 1
Reputation: 16974
Links to stylesheets need to be applied in the HEAD section of your html. If you don't want to reference the style sheet in your asp.net page directly you can either use inline styles in you user control or add the reference in the user controls code behind file. The following code is in VB.NET and was taken from an answer in this forum:
Dim Style As New HtmlControls.HtmlLink
With Style.Attributes
.Add("href", Me.ResolveUrl(Me.AppRelativeVirtualPath).Replace(" .ascx", ".css"))
.Add("type", "text/css")
.Add("rel", "stylesheet")
End With
Page.Header.Controls.Add(Style)
Upvotes: 4