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>
Użytkownik "Mark Rae [MVP]" <ma**@markNOSPAMrae.netnapisał w wiadomo¶ci
news:e8**************@TK2MSFTNGP04.phx.gbl...
"Grzegorz Klimsa" <gr*********@wp.plwrote in message
news:e3**************@TK2MSFTNGP05.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.Browser.Type == "IE")
{
objCSS.Attributes.Add("href", "IE.css");
}
else
{
objCSS.Attributes.Add("href", "FF.css");
}
objCSS.Attributes.Add("rel", "stylesheet");
objCSS.Attributes.Add("type", "text/css");
Header.Controls.Add(objCSS);
--
Mark Rae
ASP.NET MVP
http://www.markrae.net