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

H

hazz

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
 
S

Swanand Mokashi

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
 
Joined
Jan 30, 2008
Messages
1
Reaction score
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>
 
Joined
Mar 19, 2008
Messages
1
Reaction score
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 !
 
Joined
Jun 9, 2010
Messages
1
Reaction score
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.
 

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. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,733
Messages
2,569,440
Members
44,829
Latest member
PIXThurman

Latest Threads

Top