Click here to Skip to main content
15,886,258 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Dear all,
I'm stuck with this problem: in VS 2012 I've created this basic User Control, derived from System.Web.UI.UserControl:

File test.ascx.cs:

C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace B2CInterface.UC
{
    public partial class UC_Base_test : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            int a = 1; // some code here...
        }
    }
}


and the corresponding test.ascx:

ASP.NET
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="test.ascx.cs" Inherits="B2CInterface.UC.UC_Base_test" %>
<p>test</p>


Now, I've a second User Control that should be derived from the first one (UC_Base_test):

File test2.ascx.cs:

C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace B2CInterface.UC
{
    public partial class UC_Base_test2 : UC_Base_test // System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
           //other code here...
        }
    }
}


and the corresponding test2.ascx:

ASP.NET
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="test2.ascx.cs" Inherits="B2CInterface.UC.UC_Base_test2" %>


Now, when I compile I get this error:
C#
Error	12	The type or namespace name 'UC_Base_test' could not be found (are you missing a using directive or an assembly reference?)	C:\Progetti\B2CInterface\UC\Base\test2.ascx.cs	10	42	B2CInterface


I thank in advance anyone who will be able to solve this!!
PJ
Posted

1 solution

Please sepicify user control using @Reference

Assuming the control(.ascx file) is placed in Controls folder.
XML
<%@ Page Language="C#" %>
<%@ Reference Control="~/Controls/UC_Base_test.ascx" %>
 
Share this answer
 
v2
Comments
superpj70 30-Mar-13 9:55am    
Thank you very much, Kuthuparakkal!! It works! :)
Kuthuparakkal 30-Mar-13 11:59am    
Well, glad to know it helped you!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900