简体   繁体   中英

Content page cannot find ContentPlaceHolder 'ContentPlaceHolder1'

I keep get an error when I load a ContentPage inside a fancybox:

Cannot find ContentPlaceHolder 'ContentPlaceHolder1' in the master page '/MasterPage/Modal.Master', verify content control's ContentPlaceHolderID attribute in the content page.

I have this in the MasterPage (some code omitted for simplification):

<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Modal.master.cs"
Inherits="TransportadoraEDI.App.Modal" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <meta charset="utf-8" />
    <title></title>
    <meta content="width=device-width, initial-scale=1.0" name="viewport" />

    <asp:ContentPlaceHolder ID="head" runat="server">
    </asp:ContentPlaceHolder>
</head>
<body>
    <form id="form1" runat="server">

        <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>

        <div id="main-content">

            <div style="width: 800px; height: 600px">
                <asp:ContentPlaceHolder ID="cphConteudo" runat="server">
                </asp:ContentPlaceHolder>
            </div>

            <!-- jQuery -->
            <script src="../js/jquery.min.js"></script>
            <script src="../js/init.js"></script>

            <asp:ContentPlaceHolder ID="cphBlocoJs" runat="server">
            </asp:ContentPlaceHolder>

        </div>
    </form>
</body>
</html>

And this code in a ContentPage (some code omitted for simplification):

<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage/Modal.Master" 
AutoEventWireup="true" CodeBehind="FormCadNotFis.aspx.cs" Inherits="TransportadoraEDI.App.Conemb.FormCadNotFis" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="cphConteudo" runat="server">
</asp:Content>

<asp:Content ID="Content3" ContentPlaceHolderID="cphBlocoJs" runat="server">    
</asp:Content>

How it's possible to the ContentPage look for a ContentPlaceHolder that doesn't even exists?

EDIT

My open fancybox function:

$(document).ready(function () {
    function AbrirModal(url) {
        $.fancybox.open({
            fitToView: false,
            autoSize: false,
            href: url,
            //width: _width,
            //height: _height,
            type: 'iframe',
            transitionOut: 'none',
            centerOnScroll: true,
            hideOnOverlayClick: false,
            padding: 0,
            afterClose: function () {
                parent.location.reload(true);
            }
        });
    }; });

There is no ContentPlaceHolder named ' MainContent ' in your master page,

A content place holder should be in your Master page like this:

<asp:ContentPlaceHolder ID="MainContent" runat="server">

    </asp:ContentPlaceHolder>

And child pages like this:

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
</asp:Content>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM