Click here to Skip to main content
15,896,487 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
HI ALL

i try to add two CSS in my ASP web application project ,
i want to run first one for IE , and other one for Other browsers such as Chrome , firefox etc..

how can i do that ? in my master page ?
please any idea ?



thanks :)
Posted
Comments
Nathan Minier 16-Oct-15 15:09pm    
You can just roll in the IE-specific parameters in the same file, other browsers will ignore them.
sam9787 16-Oct-15 15:30pm    
how can i call my css for IE in master page ???

1 solution

Determine the browser type and then add the CSS links for those browsers. You can determine the browser using Request.Browser.Browser. For more on Request.Browser[^] object please refer to MSDN.

C#
@if(browser == "IE") {
   // Attach the CSS for Internet explorer
} else {
   // Attach the CSS for other browsers
}


For detailed documentation about browser capabilities and getting them in ASP.NET, refer to this documentation: https://msdn.microsoft.com/en-us/library/3yekbd5b.aspx[^]

Another way is by using the IE hacks, in which you add the CSS in a comment and is added to the IE only. But that is a hack, so do not use it. Anyways, here is the link for that. https://css-tricks.com/how-to-create-an-ie-only-stylesheet/[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900