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 .
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 .
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)
Try this way
<link rel="Stylesheet" type="text/css" href="<%=ResolveUrl("~/yourpath.css") %>" />
Hope this helps
Generally under in web.config you need to
<pages theme="skinfile" styleSheetTheme="Default">
So that would be available throughout the application.