I’m currently using HTML conditional statements to select a CSS file based on IE version. How do I do this on the server side instead.
<!--[if IE 6]>
<link rel="stylesheet" type="text/css" href="style/ie6.css" media="screen" />
<![endif]-->
<!--[if IE 7]>
<link rel="stylesheet" type="text/css" href="style/ie7.css" media="screen" />
<![endif]-->
<!--[if IE 8]>
<link rel="stylesheet" type="text/css" href="style/ie8.css" media="screen" />
<![endif]-->
Determine the browser type from the HTTP request:
Then render the page accordingly:
I believe you have to set the
runat="server"attribute within the<head>element of the page for this to work.This isn’t a very good way of doing it though. A better way would be to do it client-side using either JavaScript or the method used in the question.