|
Prev: dropdown list in gridview does not seem to display correct data
Next: Opinion - Everyone has one :-)
From: Grzegorz Klimsa on 2 Jul 2008 18:44 Hi ! I have a problem wiht detecting resolution of client web browser I prepare several files of css style for different browsers and different resolutions, (such as : Style_1024x768.css ; Styleff_1024x768.css; Style_1280x1024.css ; Styleff_1280x1024.css ) I want to set css style file depends on resolution browser I wrote this script to detect type of browsers, but i don't have any idea how to detect resolution ??? <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> <script runat="server"> protected void Page_Init(object sender, EventArgs e) { // Define an HtmlLink control. string type = Request.Browser.Type; HtmlLink myHtmlLink = new HtmlLink(); if (type == "IE7") { myHtmlLink.Href = "Style_1280x1024.css"; myHtmlLink.Attributes.Add("rel", "stylesheet"); myHtmlLink.Attributes.Add("type", "text/css"); // Add the HtmlLink to the Head section of the page. Page.Header.Controls.Add(myHtmlLink); } else { myHtmlLink.Href = "Styleff_10280x1024.css"; myHtmlLink.Attributes.Add("rel", "stylesheet"); myHtmlLink.Attributes.Add("type", "text/css"); // Add the HtmlLink to the Head section of the page. Page.Header.Controls.Add(myHtmlLink); } } Greetings Grzegorz
From: Juan T. Llibre on 2 Jul 2008 23:43
re: !> I want to set css style file depends on resolution browser There's many ways to do that. This Google search will help you find one you can use/adapt : http://www.google.com/search?hl=en&q=detect+browser+resolution re: !> if (type == "IE7") { !> myHtmlLink.Href = "Style_1280x1024.css"; That someone uses IE7 doesn't mean that their screen resolution is necessarily set to 1280x1024. Juan T. Llibre, asp.net MVP asp.net faq : http://asp.net.do/faq/ foros de asp.net, en espanol : http://asp.net.do/foros/ ====================================== "Grzegorz Klimsa" <grzegorzk19(a)wp.pl> wrote in message news:uxT2DVJ3IHA.2332(a)TK2MSFTNGP03.phx.gbl... > Hi ! > I have a problem wiht detecting resolution of client web browser > I prepare several files of css style for different browsers and different resolutions, > (such as : Style_1024x768.css ; Styleff_1024x768.css; Style_1280x1024.css ; Styleff_1280x1024.css ) > > I want to set css style file depends on resolution browser > > I wrote this script to detect type of browsers, but i don't have any idea how to detect resolution ??? > > <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> > <script runat="server"> > > protected void Page_Init(object sender, EventArgs e) > { > // Define an HtmlLink control. > string type = Request.Browser.Type; > HtmlLink myHtmlLink = new HtmlLink(); > > if (type == "IE7") > { > > myHtmlLink.Href = "Style_1280x1024.css"; > myHtmlLink.Attributes.Add("rel", "stylesheet"); > myHtmlLink.Attributes.Add("type", "text/css"); > // Add the HtmlLink to the Head section of the page. > Page.Header.Controls.Add(myHtmlLink); > } > else > { > myHtmlLink.Href = "Styleff_10280x1024.css"; > myHtmlLink.Attributes.Add("rel", "stylesheet"); > myHtmlLink.Attributes.Add("type", "text/css"); > // Add the HtmlLink to the Head section of the page. > Page.Header.Controls.Add(myHtmlLink); > } > > } > > Greetings > Grzegorz |