asp.net - Does Request.Browser work always as expected? -
I have a passcode to add the correct CSS file to the "head" on a browser,
When I open my page in IE8, sometimes I look at Home.css, I should actually see Home-IECSS. I have ensured that the head is not empty. Not sure anybody has experienced such a thing appreciated any comments.
I wonder why you do not do it in the HTML section ... Many websites explain it .
& lt ;! - [if IE] & gt; & Lt; Link rel = "stylesheet" type = "text / css" href = "all-ie.css" /> & Lt; [Endif] - & gt;
& lt; Link rel = "stylesheet" type = "text / css" href = "common.css" /> & Lt ;! - [if IE] & gt; & Lt; Link rel = "stylesheet" type = "text / css" href = "all-ie.css" /> & Lt; [Endif] - & gt; & Lt ;! - [If IE 6] & gt; & Lt; Link rel = "stylesheet" type = "text / css" href = "i.e.-6.0.css" /> & Lt; [Endif] - & gt; & Lt ;! - [If LT IE 6] & gt; & Lt; Link rel = "stylesheet" type = "text / css" href = "i.e.-5.0 + 5.5 css" /> & Lt; [Endif] - & gt;
Just to indicate something on your code, how to learn a refactor and how to reuse the code.
string browser name = requested Browser.Browser; String Browser View = Request Browser.Version; If (Head! = Blank) {if (browserName == "IE") {if (BrowserVersion == "6.0") AddCSS ("Home-IE6.css", Incorrect); ADCSS ("Home-IACSS", Incorrect); } And AddCSS ("home.css", incorrect); } And AddCSS ("home.css", is true);
...
Zero AddCss (string css file, bold type) {control head = page. Muster.FindControl ("stu head"); String css = string.format ("& lt; link rel = 'stylesheet' rev = 'stylesheet' href = '{0}' type = 'text / css' media = 'all' / & gt;", css file); If (Write) Answer CRS; CRS; other major. Control. Add (New Literal Control (CSS)); }
Comments
Post a Comment