reference to Composite Control

Discussion in 'ASP .Net Building Controls' started by Sparticus, Dec 19, 2005.

  1. Sparticus

    Sparticus Guest

    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, Dec 19, 2005
    #1
    1. Advertising

  2. Sparticus

    Sparticus Guest

    PS. The object variable myCustomControl is the same string used for the id
    attribute for the custom control in the html output.
     
    Sparticus, Dec 19, 2005
    #2
    1. Advertising

  3. Sparticus

    Teemu Keiski Guest

    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


    "Sparticus" <> wrote in message
    news:...
    > 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.
    >
    >
     
    Teemu Keiski, Dec 19, 2005
    #3
  4. Sparticus

    Sparticus Guest

    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
    same namespace as all other project classes!
     
    Sparticus, Dec 20, 2005
    #4
  5. Sparticus

    Sparticus Guest

    OK dudes I have sussed this one out. Since I was compiling my
    Composite\Custom control to a seperate assembly, my main assembly required
    compiling with the /r to reference the Custom Control assembly. Simple really.
     
    Sparticus, Dec 20, 2005
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    0
    Views:
    732
  2. sleigh
    Replies:
    1
    Views:
    2,706
    sleigh
    Feb 12, 2004
  3. shapper
    Replies:
    6
    Views:
    967
    shapper
    Dec 26, 2007
  4. Chad
    Replies:
    0
    Views:
    236
  5. Mike

    Composite vs non composite Controls

    Mike, Mar 10, 2005, in forum: ASP .Net Web Controls
    Replies:
    4
    Views:
    272
    Sundararajan
    Mar 11, 2005
Loading...

Share This Page