Conditional skin file in ASP.Net Theme based off of browser
Is there a way to use a skin file in a the开发者_运维百科me only when a certain browser is used?
The theme stays the same, I just want skin A to apply when a certain browser is used, and skin B when another browser is used. I know I can have server-side code to check and then set the SkinId of the control to either or, but is there another, more global way?
Thanks
You can test for what browser the user is using, and then set the theme programatically that way.
An example might be:
protected void Page_PreInit(object sender, EventArgs e)
{
System.Web.HttpBrowserCapabilities browser = Request.Browser;
if (browser.ToUpper().IndexOf("IE") >= 0)
{
Page.Theme = "BlueTheme";
}
else
{
Page.Theme = "PinkTheme";
}
}
精彩评论