1

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);
            }
        });
    }; });
5
  • Where's the fancybox part of the code? Aug 30, 2014 at 11:35
  • It's inside the init.js script. Something I forgot to mention: all the others ContentPages that use this same MasterPage are opening normally. Aug 30, 2014 at 11:41
  • Please include this bit of code in your question. Aug 30, 2014 at 12:13
  • I can't see anything in your code that would throw this error. Have you tried to debug it step-by-step? Aug 30, 2014 at 13:00
  • Yep, I tried. Checked twice for missing closing tags, javascript errors, everything. I appreciate your effort trying to help me. Next I'll try to create a new ContentPage and reuse the same code, applying it bit by bit to see where the error is. See if it changes something. Thank you @MelanciaUK. Aug 30, 2014 at 16:37

1 Answer 1

0

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>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.