error: Only Content controls are allowed directly in a content page that contains Content controls.

Discussion in 'ASP .Net' started by hazz, Apr 26, 2006.

  1. hazz

    hazz Guest

    putting a custom control in an aspx page that inherits from a master page is
    not working out for me. Any tips after getting that error?
    Also Element 'Search' is not a known element. This can occur if there is a
    compilation error in the Web site.

    <%@ Page Language="C#" MasterPageFile="~/MasterPage.master"
    AutoEventWireup="true" CodeFile="Search.aspx.cs" Inherits="Search"
    Title="Untitled Page" %>
    <%@ Register TagPrefix="uc" TagName="Search"
    Src="~\Controls\column_search_filter.ascx" %>

    <html>
    <body>
    <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1"
    Runat="Server">
    <uc:Search id="Search1"
    runat="server" />
    </asp:Content>
    </body>
    </html>


    Thank you,
    -Greg
     
    hazz, Apr 26, 2006
    #1
    1. Advertisements

  2. Where are you seeing the error ? in the aspx page runtime or compiler error

    I am not sure if it is a problem, but might be worth change the Src to
    Src="~/Controls/column_search_filter.ascx" (/ instead of \)

    HTH

    --
    Swanand Mokashi
    Microsoft Certified Solution Developer (.NET) - Early Achiever
    Microsoft Certified Application Developer (.NET)

    http://www.dotnetgenerics.com/
    DotNetGenerics.com -- anything and everything about Microsoft .NET
    technology ...

    http://www.swanandmokashi.com/
    http://www.swanandmokashi.com/HomePage/WebServices/
    Home of the Stock Quotes, Quote of the day and Horoscope web services
     
    Swanand Mokashi, Apr 26, 2006
    #2
    1. Advertisements

  3. hazz

    hazz Guest

    Thank you Swanand.
    I will revisit that issue and see if that resolves it.
    -Greg
     
    hazz, Apr 27, 2006
    #3
  4. hazz

    engtg

    Joined:
    Jan 30, 2008
    Messages:
    1
    Likes Received:
    0
    It may be late but will this work

    Try moving
    <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1"
    Runat="Server"> above <html>
    Move </asp:Content> below </html>
    You may need to remove one of your Runat="Server"

    <%@ Page Language="C#" MasterPageFile="~/MasterPage.master"
    AutoEventWireup="true" CodeFile="Search.aspx.cs" Inherits="Search"
    Title="Untitled Page" %>
    <%@ Register TagPrefix="uc" TagName="Search"
    Src="~\Controls\column_search_filter.ascx" %>

    <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1"
    Runat="Server">
    <html>
    <body>

    <uc:Search id="Search1" />

    </body>
    </html>
    </asp:Content>
     
    engtg, Jan 30, 2008
    #4
  5. hazz

    shai.wininger

    Joined:
    Mar 19, 2008
    Messages:
    1
    Likes Received:
    0
    Solution is simple

    Hi,

    Just remove the "<!DOCTYPE html ..." line in the markup of the page. It is a duplication with the one in the master page.

    good luck !
     
    shai.wininger, Mar 19, 2008
    #5
  6. hazz

    leisenstein

    Joined:
    Dec 11, 2009
    Messages:
    1
    Likes Received:
    0
    Fixed

    I was getting this error because I had 2 Content panels with the same ID.
     
    leisenstein, Dec 11, 2009
    #6
  7. hazz

    SkyUCHC

    Joined:
    Jun 9, 2010
    Messages:
    1
    Likes Received:
    0
    If you pasted from tutorial

    If you cut and pasted from the NerdDinner tutorial, insert a space before the 1st runat="server" - it was left out. Once inserted, the error goes away.
     
    SkyUCHC, Jun 9, 2010
    #7
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.