内容控件必须是内容页面中的顶级控件或引用母版页的嵌套母版页。 [英] Content controls have to be top-level controls in a content page or a nested master page that references a master page.

查看:1009
本文介绍了内容控件必须是内容页面中的顶级控件或引用母版页的嵌套母版页。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

protected void page_preinit(object sender, EventArgs e)
        {
            if (Session["username"].ToString()!= "")
            {
                if (Session["username"].ToString() == "Siva")
                   this.MasterPageFile = "~/First.master";
                else if (Session["username"].ToString() == "Ramu")
                   this.MasterPageFile = "~/Second.master";
                else if(Session["username"].ToString() == "Raju")
                  this.MasterPageFile = "~/Third.master";
            }

        }





我在这里做一个网页包含多个母版页基于用户登录



这里我得到的错误是内容控件必须是内容页面中的顶级控件或引用母版页的嵌套母版页。 br $> b $ b

请任何人给我一些建议。



Here i am doing "One webpage contain multiple master pages based on user login

Here i get error like "Content controls have to be top-level controls in a content page or a nested master page that references a master page."

please any one give me some suggestion.

推荐答案

参考 - http://stackoverflow.com/a/835978/1099247 [ ^ ]。

Refer - http://stackoverflow.com/a/835978/1099247[^].
Quote:

您的网站表单不应该包含所有标记(例如< html>标记)。由于它有一个母版页,你只需要从内容标记开始。你的aspx页面应如下所示:

Your web form shouldn't have all of that markup (like the <html> tag). Since it has a master page, you just start with the content tag. Your aspx page should look like this:

<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Default.aspx.vb" Inherits="WebUI._Default" MasterPageFile="~/Site1.Master" %>

<asp:content id="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
   This is the body!
</asp:content>



当您添加新的aspx页面时,请务必在添加新项目对话框中选中选择母版页。


When you're adding a new aspx page make sure to check "select master page" in the "add new item" dialog.


这篇关于内容控件必须是内容页面中的顶级控件或引用母版页的嵌套母版页。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆