我正在尝试建立一个母版页。我想做的是在母版页中有一个带有登录和注册链接按钮的标题(将更改为用户名并退出),并且有像 home.aspx、shoppingcart.aspx、checkout.aspx 这样的内容页面继承具有该标题的母版页。所以在那个过程中,我在母版页(First.Master)中编写了以下代码。我尝试通过页面标记中的以下代码 Inherits="SampleMasterProject.First" 继承 home.aspx 中的母版页
<body>
<form id="form1" runat="server">
<div>
<asp:ContentPlaceHolder ID="Header" runat="server">
<asp:LinkButton ID="UserNameLinkBtn" Text="UserName" runat="server"></asp:LinkButton>
<asp:LinkButton ID="PwdLinkBtn" Text="Password" runat="server"></asp:LinkButton>
</asp:ContentPlaceHolder>
</div>
</form>
</body>
但我收到以下错误
Content controls have to be top-level controls in a content page or a nested master page that references a master page.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Web.HttpException: Content controls have to be top-level controls in a content page or a nested master page that references a master page.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[HttpException (0x80004005): Content controls have to be top-level controls in a content page or a nested master page that references a master page.]
System.Web.UI.MasterPage.CreateMaster(TemplateControl owner, HttpContext context, VirtualPath masterPageFile, IDictionary contentTemplateCollection) +8836686
System.Web.UI.Page.get_Master() +54
System.Web.UI.Page.ApplyMasterPage() +15
System.Web.UI.Page.PerformPreInit() +45
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +328
请帮我。
谢谢你的期待