Groups | Blog | Home
all groups > asp.net building controls > december 2005 >

asp.net building controls : reference to Composite Control


Sparticus
12/19/2005 7:45:02 AM
Hi,

I have created a composite control which, in its simplest form inherits from
Control, implements INamingContainer and provides a method
CreateChildControls. I add my custom control to the html of an aspx page,
provide the register directive with a simple assembly name. The custom
control is a private assembly so has a simple dll in the bin directory. All
is fine, with the control rendering its html to the browser until I try and
obtain an object reference using a protected member assignment in the
code-behind class for the containing page as follows;

protected CustomControl myCustomControl;

I get the following compile error;

'The type or namespace name CustomControl could not be found (are you
missing a using directive or assembly reference?)

Any help would be appreciated.

Sparticus
12/19/2005 9:07:02 AM
PS. The object variable myCustomControl is the same string used for the id
Teemu Keiski
12/19/2005 8:03:50 PM
You need to reference that assembly so that the type is known at
code-behind. You use VS.NET? Just take reference to it using Add Reference
(it already copies the dll to bin directory)

--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
http://blogs.aspadvice.com/joteke


[quoted text, click to view]

Sparticus
12/20/2005 12:50:02 AM
Teemu,

Thanks for the reply! No, I am not using vs.net at the moment. Why? you ask.
Well for exaclty this reason. Having come from a J2EE background I like to
learn a technology in full without having an IDE put code in for me. I will
switch to using vs.net when I am confident with the .net framework. Do you
know what 'code' reference I am missing here?

PS My class definition for the composite control declares itself to be in
Sparticus
12/20/2005 9:33:02 AM
OK dudes I have sussed this one out. Since I was compiling my
Composite\Custom control to a seperate assembly, my main assembly required
AddThis Social Bookmark Button