Inherit from a Web User Control

Discussion in 'ASP .Net Building Controls' started by Magnus Strandberg, Feb 22, 2005.

  1. Hi,

    Is it possible to inherit from a web user control (*.ascx) created in a
    separate class-assembly to a local specialized control that can be used in
    an aspx-page ?
    What I want to do is to create some sort of base class library of controls
    to inherit from, and use in specific dotnet web apps.
    Any ideas ?


    /Magnus
    Magnus Strandberg, Feb 22, 2005
    #1
    1. Advertising

  2. User contrls (*.ascx) are sure handy, but they aren't very reusable across
    projects.
    To create a class library, you should start up Visual Studio and create a
    new project of type "class library" of course! This will result in Custom
    controls instead of User controls, and they are much more reusable and much
    easier to extend.

    Here's more info:
    http://SteveOrr.net/faq/UserCustom.aspx
    http://msdn.microsoft.com/library/d...l/vbconWebUserControlsVsCustomWebControls.asp

    --
    I hope this helps,
    Steve C. Orr, MCSD, MVP
    http://SteveOrr.net


    "Magnus Strandberg" <> wrote in message
    news:...
    > Hi,
    >
    > Is it possible to inherit from a web user control (*.ascx) created in a
    > separate class-assembly to a local specialized control that can be used in
    > an aspx-page ?
    > What I want to do is to create some sort of base class library of controls
    > to inherit from, and use in specific dotnet web apps.
    > Any ideas ?
    >
    >
    > /Magnus
    >
    Steve C. Orr [MVP, MCSD], Feb 22, 2005
    #2
    1. Advertising

  3. Magnus Strandberg

    MasterGaurav Guest

    Yes. You can inherit from the user controls.

    I would suggest the following:

    1. Create custom user controls without ascx files.
    2. Enhance this custom control in the ascx file.

    I would rather warn against deriving your class from the dynamically
    created user control from the ascx file. DO NOT DO that. It may work
    today, but not tomorrow if the strategy of compilation changes.



    --
    Cheers,
    Gaurav Vaish
    http://www.mastergaurav.org
    http://mastergaurav.blogspot.com
    --------------------------------
    MasterGaurav, Feb 23, 2005
    #3
  4. Thank you for your valuable advices.

    /Regards, Magnus Strandberg


    "Magnus Strandberg" <> wrote in message
    news:...
    > Hi,
    >
    > Is it possible to inherit from a web user control (*.ascx) created in a
    > separate class-assembly to a local specialized control that can be used in
    > an aspx-page ?
    > What I want to do is to create some sort of base class library of controls
    > to inherit from, and use in specific dotnet web apps.
    > Any ideas ?
    >
    >
    > /Magnus
    >
    Magnus Strandberg, Feb 23, 2005
    #4
    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. chavdar
    Replies:
    1
    Views:
    454
    John Saunders
    Jul 9, 2004
  2. CJ Taylor

    Inherit User control 2.0?

    CJ Taylor, Sep 25, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    508
    CJ Taylor
    Sep 25, 2004
  3. Danny Ni

    How to inherit an user control?

    Danny Ni, May 21, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    769
    Danny Ni
    May 21, 2005
  4. chyong

    How to inherit a web user control

    chyong, Jul 2, 2006, in forum: ASP .Net Building Controls
    Replies:
    0
    Views:
    99
    chyong
    Jul 2, 2006
  5. chavdar

    How to Inherit web user control?

    chavdar, Jul 9, 2004, in forum: ASP .Net Web Controls
    Replies:
    2
    Views:
    109
    Chavdar Bilyanski
    Jul 12, 2004
Loading...

Share This Page