Barrett Kuethen
Barrett Kuethen

Reputation: 1914

How do I apply a stylesheet on page leave in asp.net?

I'm new to asp.net and don't know if this is possible.

My goal is that if the client is leaving a certain page "current page" that a specific style sheet would be applied on a master-page (which would be for every other page on the site).

I would think it would be something like...

I should note- all the links on the current page are regular links. I'd like to accomplish this without changing each link to an asp control.

Any help is greatly appreciated.

Thanks!

Upvotes: 2

Views: 201

Answers (1)

steven sweeney
steven sweeney

Reputation: 56

I think if you used the url /default.aspx?css=1 or whatever, then you can use something like

if request.querystring("css") = 1 then
Dim cssLink As New HtmlLink()
cssLink.Href = "~/styles.css"
cssLink.Attributes.Add("rel", "stylesheet")
cssLink.Attributes.Add("type", "text/css")
Header.Controls.Add(cssLink)
end if

I haven't tried this or anything but should be ok.

Similar if you use

session("css") = "1" 

when you click the link..

if session("css") = 1 then... 

Upvotes: 1

Related Questions