Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. custom ContentPlaceHolder?

custom ContentPlaceHolder?

Scheduled Pinned Locked Moved ASP.NET
helpquestion
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    Roman Nurik
    wrote on last edited by
    #1

    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

    M 1 Reply Last reply
    0
    • R Roman Nurik

      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

      M Offline
      M Offline
      minhpc_bk
      wrote on last edited by
      #2

      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 the ID property of the custom ContenPlaceHolder in the master page.

      R 1 Reply Last reply
      0
      • M minhpc_bk

        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 the ID property of the custom ContenPlaceHolder in the master page.

        R Offline
        R Offline
        Roman Nurik
        wrote on last edited by
        #3

        I've made sure of that, I still have the same problem.. thank you for your help..

        r -€

        M 1 Reply Last reply
        0
        • R Roman Nurik

          I've made sure of that, I still have the same problem.. thank you for your help..

          r -€

          M Offline
          M Offline
          minhpc_bk
          wrote on last edited by
          #4

          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.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups