473,625 Members | 3,210 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Detecting resolution of client browser

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_1024x76 8.css; Style_1280x1024 .css ;
Styleff_1280x10 24.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="Defau lt.aspx.cs"
Inherits="_Defa ult" %>
<script runat="server">

protected void Page_Init(objec t sender, EventArgs e)
{
// Define an HtmlLink control.
string type = Request.Browser .Type;
HtmlLink myHtmlLink = new HtmlLink();

if (type == "IE7")
{

myHtmlLink.Href = "Style_1280x102 4.css";
myHtmlLink.Attr ibutes.Add("rel ", "stylesheet ");
myHtmlLink.Attr ibutes.Add("typ e", "text/css");
// Add the HtmlLink to the Head section of the page.
Page.Header.Con trols.Add(myHtm lLink);
}
else
{
myHtmlLink.Href = "Styleff_10280x 1024.css";
myHtmlLink.Attr ibutes.Add("rel ", "stylesheet ");
myHtmlLink.Attr ibutes.Add("typ e", "text/css");
// Add the HtmlLink to the Head section of the page.
Page.Header.Con trols.Add(myHtm lLink);
}

}

Greetings
Grzegorz

Jul 2 '08 #1
1 4145
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...ser+resolution

re:
! if (type == "IE7")
{
! myHtmlLink.Href = "Style_1280x102 4.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" <gr*********@wp .plwrote in message news:ux******** ******@TK2MSFTN GP03.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_1024x76 8.css; Style_1280x1024 .css ; Styleff_1280x10 24.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="Defau lt.aspx.cs" Inherits="_Defa ult" %>
<script runat="server">

protected void Page_Init(objec t sender, EventArgs e)
{
// Define an HtmlLink control.
string type = Request.Browser .Type;
HtmlLink myHtmlLink = new HtmlLink();

if (type == "IE7")
{

myHtmlLink.Href = "Style_1280x102 4.css";
myHtmlLink.Attr ibutes.Add("rel ", "stylesheet ");
myHtmlLink.Attr ibutes.Add("typ e", "text/css");
// Add the HtmlLink to the Head section of the page.
Page.Header.Con trols.Add(myHtm lLink);
}
else
{
myHtmlLink.Href = "Styleff_10280x 1024.css";
myHtmlLink.Attr ibutes.Add("rel ", "stylesheet ");
myHtmlLink.Attr ibutes.Add("typ e", "text/css");
// Add the HtmlLink to the Head section of the page.
Page.Header.Con trols.Add(myHtm lLink);
}

}

Greetings
Grzegorz

Jul 3 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
2731
by: Erik Bethke | last post by:
Hello All, I am trying to clean up some polish bugs with the Shanghai game I am working on and I am currently stuck on trying to get the right event for detecting when the user has changed the desktop resolution. I have tried trapping the following events: 1) SDL_ACTIVEEVENT 2) SDL_VIDEOEXPOSE
1
2855
by: Erik Bethke | last post by:
Hello All, I am trying to clean up some polish bugs with the Shanghai game I am working on and I am currently stuck on trying to get the right event for detecting when the user has changed the desktop resolution. I have tried trapping the following events: 1) SDL_ACTIVEEVENT 2) SDL_VIDEOEXPOSE 3) SDL_VIDEORESIZE
2
1859
by: Lee Mundie | last post by:
Hi, Does anyone know where I can get a script for a pop-up where I can control fixed positioning of a popup based on browser resolution? two res's: 800 x 600 and 1024 x 768 Thanks in advance Lee
5
4402
by: Chris | last post by:
After exhausting my search on the MS website, I can't find a straight answer. I fin dit hard to believe that MS left our something so useful in ASP.NET as screen resolution detection. Problem: I would like to detect, get values for, the screen resolution in px but in a code behind. Is this possible? There is a System.Windows.Forms.Screen class for the Windows client side, why are there none for browser/ASP.NET client?
25
2891
by: Ryan Stewart | last post by:
I'm working on a project to collect web application usage statistics. What are the recommended ways of detecting whether a browser is JavaScript enabled and/or capable? Obviously I can write a script to invoke something on the server, and if it works, then it works. Is there a better way? I'm looking for the least intrusive way of doing it, from a web application point of view. i.e. I'd like to be able to drop this into an existing...
2
3031
by: Sam-Kiwi | last post by:
I've spent the last 6 months developing a pay-per-download website using ASP.NET Users purchase documents and then download them. The intention is that users are only charged for documents they successfuly download. My problem revolves around detecting a successful download, the steps I take to handle the download are as follows:
9
3053
by: SHarris | last post by:
Hello, In our new intranet ASP.NET project, two requirements are that the browser accept cookies AND JavaScript. We are requiring the use of Internet Explorer 6+. 1. Using C# in an ASP.NET application, how can we code the project to check to make sure the browser accepts cookies? 2. Where would we put this code? In Global.asax? 3. Using C# in an ASP.NET application, how can we code the project to detect and make sure the browser...
79
3747
by: VK | last post by:
I wandering about the common proctice of some UA's producers to spoof the UA string to pretend to be another browser (most often IE). Shouldn't it be considered as a trademark violation of the relevant name owner? If I make a whisky and call it "Jack Daniels", I most probably will have some serious legal problems. "Mozilla" partially appeared because NCSA stopped them from using "Mosaic" in the UA string. Is it some different...
8
5346
by: Bjorn Sagbakken | last post by:
Can screen resolution be detected with server code (in Page_Load) ? I have tried this: public int Width = Convert.ToInt32(System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Width); public int Height = Convert.ToInt32(System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Height); and sure enough, I get a couple of numbers; Width=1024 and Height=738 when running at 1024x768 - but I also get the same numbers when running at
0
8259
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8696
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8358
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6119
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5571
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4090
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4195
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1805
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1504
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.