我在fancybox中加载ContentPage时出现错误:
Cannot find ContentPlaceHolder 'ContentPlaceHolder1' in the master page '/MasterPage/Modal.Master', verify content control's ContentPlaceHolderID attribute in the content page.
我在MasterPage中有这个(为了简化省略了一些代码):
<%@ 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>
这个代码在ContentPage中(为简化起见省略了一些代码):
<%@ 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>
ContentPage如何查找甚至不存在的ContentPlaceHolder?
修改
我的开放式fancybox功能:
$(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);
}
});
}; });
答案 0 :(得分:0)
主页中没有名为“ MainContent ”的 ContentPlaceHolder ,
内容占位符应该在您的母版页中,如下所示:
unsigned char
和这样的子页面:
<asp:ContentPlaceHolder ID="MainContent" runat="server">
</asp:ContentPlaceHolder>