0

I have the following control:

public partial class Controls_ProductPanel : System.Web.UI.UserControl
{
    private int _ProductID;
    public int ProductID
    {
        get
        {
            return _ProductID;
        }
        set
        {
            _ProductID = value;
        }
    }

    protected void Page_Load(object sender, EventArgs e)
    {

    }
}

I want be be able to add it to a page like this:

Controls_ProductPanel panel = new Controls_ProductPanel();
panel.ProductID = 2;
Page.Controls.Add(panel);

But Visual Studio doesn't seem to reconise Controls_ProductPanel

I get:

 The type or namespace name 'Controls_ProductPanel' could not be found. (Are you missing a using directive or an assembly reference?)
gunwin
  • 4,578
  • 5
  • 37
  • 59

2 Answers2

1

Managed to solve this, I had to put the register tag on the .aspx page. This allowed me to access it's type.

 <%@ Register TagName="ProductPanel" TagPrefix="uc" Src="~/Controls/ProductPanel.ascx" %>
gunwin
  • 4,578
  • 5
  • 37
  • 59
-1

look at this thread:

The type or namespace name could not be found

hope it helps

Community
  • 1
  • 1
user2132046
  • 95
  • 1
  • 2
  • 7
  • It's not a client profiling issue. This is a Web Site, not a project, and certainly not a multi-project solution. The link you posted solves a namespace problem. This is a type. – gunwin Mar 08 '13 at 15:31