Usercontrol derived from Usercontrol without double Html Code

Discussion in 'ASP .Net Web Controls' started by Reik, Apr 12, 2005.

  1. Reik

    Reik Guest

    Hi everyone,
    lets say I have written a usercontrol called url.ascx. The Html portion of
    this usercontrols contains a single textfield to enter a URL. The entered URL
    is handled in the code behind, checked for syntax bla bla..
    Now Iam writing a second usercontrol called link.ascx that derives from url.
    In link.ascx I have another textfield where the user can enter the text of a
    link. Still I want to display the textfield for the URL. So basically I want
    the Html from the url.ascx to be displayed above the link.ascx. Also if the
    Page is posted, I want the codebehind in url.ascx to validate the user input
    in the url textbox and the codebehind for link.ascx to handle the user input
    in the linktext textbox. Is that possible? I dont wanna double all the Html
    code when deriving a usercontrol.
    Reik, Apr 12, 2005
    #1
    1. Advertising

  2. Reik

    Brock Allen Guest

    You should use containment not inheritance. Have link.ascx create an instance
    of url.ascx via the LoadControl API.

    -Brock
    DevelopMentor
    http://staff.develop.com/ballen



    > Hi everyone,
    > lets say I have written a usercontrol called url.ascx. The Html
    > portion of
    > this usercontrols contains a single textfield to enter a URL. The
    > entered URL
    > is handled in the code behind, checked for syntax bla bla..
    > Now Iam writing a second usercontrol called link.ascx that derives
    > from url.
    > In link.ascx I have another textfield where the user can enter the
    > text of a
    > link. Still I want to display the textfield for the URL. So basically
    > I want
    > the Html from the url.ascx to be displayed above the link.ascx. Also
    > if the
    > Page is posted, I want the codebehind in url.ascx to validate the user
    > input
    > in the url textbox and the codebehind for link.ascx to handle the user
    > input
    > in the linktext textbox. Is that possible? I dont wanna double all the
    > Html
    > code when deriving a usercontrol.
    Brock Allen, Apr 12, 2005
    #2
    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. =?Utf-8?B?Q2FwdGFpbiBTZW5zaWJsZQ==?=

    Usercontrol derived from Usercontrol - masterpage init is fired tw

    =?Utf-8?B?Q2FwdGFpbiBTZW5zaWJsZQ==?=, Feb 3, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    449
    =?Utf-8?B?Q2FwdGFpbiBTZW5zaWJsZQ==?=
    Feb 3, 2006
  2. Sydex
    Replies:
    12
    Views:
    6,453
    Victor Bazarov
    Feb 17, 2005
  3. Replies:
    4
    Views:
    390
    Alf P. Steinbach
    May 23, 2007
  4. Replies:
    1
    Views:
    385
    myork
    May 23, 2007
  5. Replies:
    1
    Views:
    374
    Victor Bazarov
    May 23, 2007
Loading...

Share This Page