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. Advertisements

  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. Advertisements

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. Craig Kenisston

    HTML code warnings in asp.net html code view

    Craig Kenisston, Oct 7, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    2,386
    Martin Dechev
    Oct 7, 2004
  2. RKT
    Replies:
    2
    Views:
    654
    Teemu Keiski
    Jan 28, 2006
  3. =?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:
    561
    =?Utf-8?B?Q2FwdGFpbiBTZW5zaWJsZQ==?=
    Feb 3, 2006
  4. Sydex
    Replies:
    12
    Views:
    7,200
    Victor Bazarov
    Feb 17, 2005
  5. Replies:
    4
    Views:
    685
    Alf P. Steinbach
    May 23, 2007
  6. Replies:
    1
    Views:
    644
    myork
    May 23, 2007
  7. Replies:
    1
    Views:
    549
    Victor Bazarov
    May 23, 2007
  8. David
    Replies:
    3
    Views:
    616
    Grizlyk
    Jan 29, 2008
Loading...