cssasp.netvb.netstylesheetcontent-pages

Programmatically added stylesheet ASP.NET (VB)


I'm currently programmatically adding a stylesheet to my content page using VB:

Dim link As New HtmlLink()
link.Attributes.Add("rel", "stylesheet")
link.Attributes.Add("type", "text/css")
link.Href = "Styles/AddNewModelStyles.css"
Me.Page.Header.Controls.Add(link)

At first glance, this seems to be working as my web page is formatted properly. However, I added new styling to the stylesheet and nothing happened. I completely removed all styling from the stylesheet, refreshed the page, and nothing changed. It seems to me like the original stylesheet is being cached, but I can't figure out how to clear the cache. I've tried F5, Shift+F5, closing browser and opening new, all to no avail. Anyone have any ideas why this is happening?


Solution

  • I was able to figure out the solution to my problem by using Inspect element to find where the stylesheets were being loaded in. When you programmatically add a stylesheet to a content page, the stylesheet link gets added to the master web page head tag, not the content page head tag. My stylesheet was ultimately in the wrong directory (the stylesheet directory of the content page, NOT of the master page), and moving it to the master page's directory solved the issue.