473,396 Members | 1,987 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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_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

Jul 2 '08 #1
1 4129
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_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" <gr*********@wp.plwrote in message news:ux**************@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

Jul 3 '08 #2

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

Similar topics

0
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...
1
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...
2
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...
5
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:...
25
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...
2
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...
9
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...
79
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...
8
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...

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.