sick_cherry
sick_cherry

Reputation: 21

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?

Upvotes: 1

Views: 456

Answers (2)

sick_cherry
sick_cherry

Reputation: 21

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.

Upvotes: 0

AGrammerPro
AGrammerPro

Reputation: 322

Internet Explorer Go inside your browsers tools and select -> Internet Options -> General -> Browsing History -> Settings -> View Files

Select all of them and delete them and reopen your browser.

Google Chrome Ctrl+Shift+Del -> Select from the beginning of time in the drop down -> Clear Browsing Data

Upvotes: 1

Related Questions