473,788 Members | 2,744 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Detecting browser

Hello

I have problem with ASP.NET in C# language.

I prepare two files of css style, one for ie ,second for firefox
I want to set css style file depends on browser type
I know how pull out info about sort of browser from browser (using
Request.Browser .Type),
but i have problem, how to load css file after execute Request.Browser .Type
method in head
section my ASP.NET page ???

Greetings
Grzegorz

Jun 27 '08 #1
3 1343
"Grzegorz Klimsa" <gr*********@wp .plwrote in message
news:e3******** ******@TK2MSFTN GP05.phx.gbl...
I prepare two files of css style, one for ie ,second for firefox
I want to set css style file depends on browser type
I know how pull out info about sort of browser from browser (using
Request.Browser .Type),
but i have problem, how to load css file after execute
Request.Browser .Type method in head section my ASP.NET page ???
HtmlLink objCSS = new HtmlLink();
if (Request.Browse r.Type == "IE")
{
objCSS.Attribut es.Add("href", "IE.css");
}
else
{
objCSS.Attribut es.Add("href", "FF.css");
}
objCSS.Attribut es.Add("rel", "stylesheet ");
objCSS.Attribut es.Add("type", "text/css");
Header.Controls .Add(objCSS);
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Jun 27 '08 #2
I wrote smilar script, and put in to my default.aspx page and work correctly
:)
but in my solution i have another pages which use MasterPage.mast er
I copy & paste the same script to MasterPage.mast er but CssStyle don't load.

What is the reason of this behaviour and how to reslove this problem ???
<%@ Page Language="C#"%>
<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 = "Styl.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.cs s";
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);
}

}
</script>

U¿ytkownik "Mark Rae [MVP]" <ma**@markNOSPA Mrae.netnapisa³ w wiadomo¶ci
news:e8******** ******@TK2MSFTN GP04.phx.gbl...
"Grzegorz Klimsa" <gr*********@wp .plwrote in message
news:e3******** ******@TK2MSFTN GP05.phx.gbl...
>I prepare two files of css style, one for ie ,second for firefox
I want to set css style file depends on browser type
I know how pull out info about sort of browser from browser (using
Request.Browse r.Type),
but i have problem, how to load css file after execute
Request.Browse r.Type method in head section my ASP.NET page ???

HtmlLink objCSS = new HtmlLink();
if (Request.Browse r.Type == "IE")
{
objCSS.Attribut es.Add("href", "IE.css");
}
else
{
objCSS.Attribut es.Add("href", "FF.css");
}
objCSS.Attribut es.Add("rel", "stylesheet ");
objCSS.Attribut es.Add("type", "text/css");
Header.Controls .Add(objCSS);
--
Mark Rae
ASP.NET MVP
http://www.markrae.net
Jun 27 '08 #3
"Grzegorz Klimsa" <gr*********@wp .plwrote in message
news:O4******** ******@TK2MSFTN GP03.phx.gbl...
but in my solution I have another pages which use MasterPage.mast er
I copy & paste the same script to MasterPage.mast er but CssStyle don't
load.
That's correct.
What is the reason of this behaviour
Content pages don't have headers...
and how to reslove this problem ???
Master.Header.C ontrols.Add(myH tmlLink);
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Jun 27 '08 #4

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

Similar topics

10
4122
by: Frances Del Rio | last post by:
pls, why is this not working? <SCRIPT language=JavaScript type="text/javascript"> var br = '<SCRIPT language=Javascript' br += 'src="js_pop.js" type="text/javascript">' br += '</SCRIPT>' var op = '<SCRIPT language=Javascript' op += 'src="js_pop-op.js" type="text/javascript">' op += '</SCRIPT>' if (navigator.userAgent.indexOf('Opera') != -1 ) {
25
2922
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...
3
1857
by: raptor | last post by:
hi, how to detect opera..it seems that even opera8 doesnt support xmlhttp fully (.i.e. sendRequestHeader). I ask this 'cause opera seems to mimic IE, at least in the preferences ?! I havent used opera till now, but it seems very buggy piece of software !! I have one very annoyng problem, fighting already ~4 hours. I found that if I use something like this in table (test are
1
1274
by: Sharkbait | last post by:
We are trying to record browser information when a customer comes to our site. I have been able to get most basic browser information using both asp and asp.net. The only thing I’m missing is the ability to detect plug-ins. Does anyone know how I can access the plug-in collection in IE? I have not found any clear way of doing it on the internet I’m starting to think I am headed down the wrong path. Maybe IE doesn‘t call it a plug-in...
2
3041
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:
3
3613
by: regtrashcan | last post by:
I have a webpage that detects whether Shockwave Player is installed and the version number. The javascript/vbscript that I use has worked fine until the latest release of the Shockwave Player. I am still able to detect the Shockwave Player and the version number when using Firefox/Netscape, but not with IE. I have my own detection script that I use, but I've also used the detection scripts supplied from Macromedia, but it still won't...
79
3797
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...
1
2319
by: Mango | last post by:
I'm trying to print some text in a very specific position on a page, so that it will show through the window of an envelope when folded. This is easy to do, as long as the browser's print margins are set to 0, or I subtract the width of the margins from the position of the text. My question is: is there a technique for detecting browser print margins? It'd be nice not to have to warn users to set them to something specific.
1
4153
by: Grzegorz Klimsa | last post by:
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
15
4233
by: RobG | last post by:
When using createEvent, an eventType parameter must be provided as an argument. This can be one of those specified in DOM 2 or 3 Events, or it might be a proprietary eventType. My problem is testing for support of particular eventTypes - the DOM 2 Events Interface DocumentEvent says that if the eventType is not supported, it throws a DOM exception. This makes testing rather tough - if you try something like: if (document &&...
0
9656
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
9498
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9969
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8995
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7519
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
6750
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
5403
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
5538
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4074
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.