Home All Groups Group Topic Archive Search About

Usercontrol derived from Usercontrol without double Html Code

Author
12 Apr 2005 4:19 PM
Reik
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.

Author
12 Apr 2005 4:34 PM
Brock Allen
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



Show quoteHide quote
> 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.