ASP.NET WebForms Dynamically Selecting MasterPages
时间:2011-03-11 来源:eolande
http://www.msjoe.com/2011/03/asp-net-webforms-dynamically-selecting-masterpages/
protected override void OnPreInit(EventArgs e) { base.OnPreInit(e); string mystr = Request.Browser.Type; if (mystr == "IE7") { this.MasterPageFile = "~/site.master"; } else { this.MasterPageFile = "~/site1.master"; } }
<%@ Page Title="" Language="C#" AutoEventWireup="true" CodeBehind="Skin.aspx.cs" Inherits="JqueryTest.Skin" %> <asp:content id="Content1" contentplaceholderid="HeadContent" runat="server"> </asp:content> <asp:content id="Content2" contentplaceholderid="MainContent" runat="server"> 123 </asp:content>
相关阅读 更多 +