Click here to Skip to main content
12,076,216 members (37,562 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C# .NET WebForms .NET4.5
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:

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:

<%@ 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:

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:

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

Now, when I compile I get this error:
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 29-Mar-13 1:23am

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

Please sepicify user control using @Reference

Assuming the control(.ascx file) is placed in Controls folder.
<%@ Page Language="C#" %>
<%@ Reference Control="~/Controls/UC_Base_test.ascx" %>
  Permalink  
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)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web03 | 2.8.160208.1 | Last Updated 30 Mar 2013
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100