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