Richard77
Richard77

Reputation: 21621

asp.net user control is not displaying: Unrecognized namespace

This is how a register the control on the page:

<%@ Register TagPrefix="uc" TagName="Pcp" Src="../../Controls/ClientPayement.ascx" %>

And this is how I use it:

<uc1:Pcp ID = "pcpClient1"></uc1:Pcp> 

I don't know why uc1 has a green underline warning. When I hover over it, it says: "Unrecognized namespace uc1". And the user control is not displaying on the page.

Am I missing something? Yet this tutorial says that this is all I need to do.

Upvotes: 1

Views: 1140

Answers (2)

juan.facorro
juan.facorro

Reputation: 9930

You are specifying a uc prefix in <%@ Register TagPrefix="uc" .. so that's the one you should use:

<uc:Pcp ID = "pcpClient1"></uc:Pcp> 

Or you could change the declared prefix:

<%@ Register TagPrefix="uc1" TagName="Pcp" Src="../../Controls/ClientPayement.ascx" %>

And use the control as you posted in the question:

<uc1:Pcp ID = "pcpClient1"></uc1:Pcp> 

EDIT

As Shai Cohen pointed out in another answer, you are also missing the runat="server" from the usercontrol tag.

<uc1:Pcp ID = "pcpClient1" runat="server"></uc1:Pcp> 

Upvotes: 5

Shai Cohen
Shai Cohen

Reputation: 6249

In addition to Juan's answer, you are also missing runat="server".

Upvotes: 0

Related Questions