How to create an object of a partial class user control in a seperate public class?

Discussion in 'ASP .Net Web Controls' started by MurdockSE, Sep 13, 2006.

  1. MurdockSE

    MurdockSE Guest

    Greetings. I am upgrading an older site which used ASP .NET 1.1 and VB
    as the code-behind. I've given up on trying to automatically update it,
    and I started re-building it a page at a time to ASP .NET 2.0
    standards. Everything has been successful (thank god), but I have one
    bug left that is vexing me. The programmer is attempting to create an
    object of a user control for use in a public class. For example, the
    'public' class itself is known as Policy, and is in the pre-verbial
    App_Code directory. Inside that class it is attempting to create
    objects from user controls which cannot be in the App_Code folder. The
    user controls are inside a folder known as "uc", and they are partial
    classes, inheriting the user control class.

    For example, this is the headers of a user control code-behind know as
    "address.ascx.vb". It is in a folder call "uc" in the main website
    root.

    Partial Class uc_address
    Inherits System.Web.UI.UserControl

    That is it's declaration. It works perfectly fine in other web forms,
    etcetera, as a normal user control would be expected to.

    Now, the problem:

    They also have the public class "Policy", as stated before, placed into
    the App_Code folder :

    Public Class Policy
    Inherits System.Web.UI.Page
    'user controls
    Protected ucAddress As uc_address

    Now, as you can see above, the programmer attempts to create an object
    of a user control within the App_Code folder. Again, having rebuilt it
    from ASP .NET 1.1 to 2.0 is the likely the fundamental issue here.

    The questions:

    1.) How do I properly declare an object based upon a partial class user
    control in a public class in ASP .NET 2.0?

    2.) Is there another way entirely to do this?

    The interesting part:
    I can COPY and PASTE the address.ascx.vb file into the App_Code folder,
    and the object can be declared in the public class! But the catch is
    that it refers to items within the address.ascx control page! ** , and
    if I import both of the files into App_Code, it errors out saying that
    App_Code cannot contain that type of file.

    Thanks for any help you might be able to provide with this problem,
    Peter Robbins
     
    MurdockSE, Sep 13, 2006
    #1
    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. Charles A. Lackman
    Replies:
    1
    Views:
    1,439
    smith
    Dec 8, 2004
  2. SpamProof
    Replies:
    0
    Views:
    636
    SpamProof
    Oct 21, 2003
  3. Billy
    Replies:
    2
    Views:
    527
    Billy
    Feb 1, 2006
  4. DaveLessnau
    Replies:
    3
    Views:
    447
    Howard
    May 16, 2005
  5. moondaddy
    Replies:
    2
    Views:
    605
    Steven Cheng[MSFT]
    Oct 16, 2006
Loading...

Share This Page