Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# 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 at 30-Mar-13 9:55am
   
Thank you very much, Kuthuparakkal!! It works! :)
Kuthuparakkal at 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
0 OriginalGriff 5,170
1 DamithSL 4,357
2 Maciej Los 3,750
3 Kornfeld Eliyahu Peter 3,470
4 Sergey Alexandrovich Kryukov 2,851


Advertise | Privacy | Mobile
Web03 | 2.8.141216.1 | Last Updated 30 Mar 2013
Copyright © CodeProject, 1999-2014
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