custom ContentPlaceHolder?
-
Hey, I have derived a class from
ContentPlaceHolder
to control what types of controls can be placed into the master page as content. However, I keep getting this error:Cannot find ContentPlaceHolder 'SomeContent' in the master page
'MyMasterPage.master', verify content control's ContentPlaceHolderID
attribute in the content page.The error makes sense, since the place holder isn't a direct ContentPlaceHolder, but instead, a derived class.. Has anyone encountered this type of problem? I can't override the CreateMaster function in the MasterPage class since it's not overridable Any suggestions would help! Thanks
r -€
-- modified at 20:16 Saturday 12th November, 2005
-
Hey, I have derived a class from
ContentPlaceHolder
to control what types of controls can be placed into the master page as content. However, I keep getting this error:Cannot find ContentPlaceHolder 'SomeContent' in the master page
'MyMasterPage.master', verify content control's ContentPlaceHolderID
attribute in the content page.The error makes sense, since the place holder isn't a direct ContentPlaceHolder, but instead, a derived class.. Has anyone encountered this type of problem? I can't override the CreateMaster function in the MasterPage class since it's not overridable Any suggestions would help! Thanks
r -€
-- modified at 20:16 Saturday 12th November, 2005
Hi there, If you still haven't resolved your issue, then you simply need to make sure that the value of the
ContentPlaceHolderID
property of the Content control in the content page should be the same as the value of theID
property of the custom ContenPlaceHolder in the master page. -
Hi there, If you still haven't resolved your issue, then you simply need to make sure that the value of the
ContentPlaceHolderID
property of the Content control in the content page should be the same as the value of theID
property of the custom ContenPlaceHolder in the master page.I've made sure of that, I still have the same problem.. thank you for your help..
r -€
-
I've made sure of that, I still have the same problem.. thank you for your help..
r -€
Below is what I have tried so far to make sure that I can create a custom ContentPlaceHolder class by superclassing the current holder. + I simply create a custom ContentPlaceHolder as below, and I prefer to put it in a separate project.
namespace WebControlLibrary1
{
[ToolboxData("<{0}:CustomContentPlaceHolder runat=server></{0}:CustomContentPlaceHolder>")]
public class CustomContentPlaceHolder : ContentPlaceHolder
{
public CustomContentPlaceHolder()
: base()
{ }
}
}+ In the web project, the master page simply looks like:
<%@ Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage.master.cs" Inherits="MasterPage" %>
<%@ Register Assembly="WebControlLibrary1" Namespace="WebControlLibrary1" TagPrefix="cc1" %>...
<body>
<form id="form1" runat="server">
<div>
<cc1:CustomContentPlaceHolder ID="CustomContentPlaceHolder1" runat="server">
</cc1:CustomContentPlaceHolder>
</div>
</form>
</body>
</html>and the content page:
<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="Default2.aspx.cs"
Inherits="Default2" Title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="CustomContentPlaceHolder1" Runat="Server">
<h3>This is the content page</h3>
</asp:Content>Though the designer complains that it could not find the
CustomContentPlaceHolder1
in the current master page. but it can be built successfully, and it is working.