在layout目录下新建aspx文件(注意aspx文件可以存放在layout目录的子目录中,但不可以存放在layout目录的子网站中),文件内容如下:
Code
<%@ Page Language="C#" AutoEventWireup="true" %>
<script runat="server">
protected override void OnPreInit(EventArgs e)
{
base.OnPreInit(e);
this.MasterPageFile = Microsoft.SharePoint.SPContext.Current.Web.MasterUrl;
//this.MasterPageFile = base.Web.MasterUrl;
}
</script>
<asp:Content ID="Content1" ContentPlaceHolderID="PlaceHolderMain" runat="server">
<asp:Label ID="Label1" runat="server" Text="hello"></asp:Label>
</asp:Content>