Detecting browser

G

Grzegorz Klimsa

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
 
G

Grzegorz Klimsa

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.master
I copy & paste the same script to MasterPage.master 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(object sender, EventArgs e)
{
// Define an HtmlLink control.
string type = Request.Browser.Type;
HtmlLink myHtmlLink = new HtmlLink();


if (type == "IE7")
{
myHtmlLink.Href = "Styl.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.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);
}

}
</script>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top