Is there a way to specify CSS only if the browser is IE?

Platform: ASP.NET| Category: Miscellaneous

You can examine the Request.UserAgent to check if the browser was IE, define a custom HtmlGenericControl type representing your stylesheet link and set the href property on it depending on if the browser was IE.


<LINK rel=stylesheet runat='server' id='lnkStyle'> 

Where LINK is a HtmlGenericControl. You could then do something like this:

VB.NET


lnkStyle.Attributes('href') = 'ie/styles.css' 

C#


lnkStyle.Attributes['href'] = 'ie/styles.css' ;

Share with

Related FAQs

Couldn't find the FAQs you're looking for?

Please submit your question and answer.