I want to divide my styles and scripts according to user-agent(mobile , ie , chrome-ff).How can control and allow include or not ?
maybe for ie i can use < !–[if IE] > , but how about others ?
Somebody advice me plz , thx
<head runat="server" id="head">
<%--Only mobile--%>
<link href="Styles/CommonMobile.css" rel="stylesheet" type="text/css"/>
<link href="Styles/SiteMobile.css" rel="stylesheet" type="text/css"/>
<script src="Scripts/CommonMobile.js" type="text/javascript"></script>
<script src="Scripts/SiteMobile.js" type="text/javascript"></script>
<%--All but IE --%>
<link href="Styles/GeneralView.css" rel="stylesheet" type="text/css" />
<script src="Scripts/GeneralView.js" type="text/javascript"></script>
<%--Only IE --%>
<link href="Styles/IE.css" rel="stylesheet" type="text/css" />
<script src="Scripts/IE.js" type="text/javascript"></script>
<%--Always--%>
<link href="Styles/Common.css" rel="stylesheet" type="text/css" />
<script src="Scripts/Common.js" type="text/javascript"></script>
</head>
A nice way is to warp them with a Literal and open it or not on code behind. I say Literal because is one of the few controls that can run inside the header and leave no extra code.
So I do it that way
and
[*] tested and working.
A Different way is again to use the
Request.Browser.Browserand fully render the css and javascript again inside a Literal, or even harder to create the controls using the Controls.Add, but all of that is much more code than this.