[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.aspnet.buildingcontrols

user control not visible from code file

boydrek

2/3/2009 10:35:00 PM

Hi,
I have a user control myUC defined as follows:

cs file:
namespace myNamespace
{
public partial class myUC : System.Web.UI.UserControl
{
....
}
}

ascx file:
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="myUC.ascx.cs"
Inherits="myNamespace.myUC" %>

<someCode>
....
</someCode>

And i have a static class MyHelperClass in which i want to do something like
this:

using ... //all the using statements needed
using myNamespace;

public static class MyHelperClass
{
public static void MyMethod(Control parent)
{
myUC uc = (myUC) parent.Page.LoadControl("path to myUC control")
;
parent.Controls.Add(uc);
}
}

in which i want to dynamically add my user control to the parent control
given to the method.

The problem is that my user control is not visible in the MyHelperClass and i
get a "are you missing a using directive or an assembly reference" error.

Anyone know why this happens or how to get around it?

1 Answer

Trisped

2/20/2009 9:58:00 PM

0

I have the same problem except I am trying to create the user control (TLEUC)
in Default.aspx.cs

For example Default.aspx.cs contians the following:

....
protected void makePBTN()
{
....
TLEUC line;
....
}
....

The annoying thing is that sometimes it builds and sometimes it gives the
following error message:
"The type or namespace name 'TLEUC' could not be found (are you missing a
using directive or an assembly reference?)"