Re: Howto inherit from an exisiting webcontrol in VS 2005
- From: "Van den Driessche Willy" <willy.van.den.driessche@xxxxxxxxx>
- Date: Wed, 6 Sep 2006 12:55:07 +0200
You just create a class (vb sample)
class myClass
inherits system.web.ui.webcontrols.button
end class
AFAIK you can put this class in the app_code folder. A "better" idea is to
create a webcontrol library (a DLL) and put the new control in there. In
you website project you put a reference to this webcontrol library (this
will copy it to the bin directory an VS2005 will make sure changes propagate
upon build)
To use it in your page, you can either use the @register directive in the
aspx markup, or register you control once and for all in the web.config of
your web application.
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
<system.web>
<controls>
<add
assembly="YourAssemblyName" namespace="yourNameSpace"
tagPrefix="XYZ" />
</controls>
</system.web>
</configuration>
afterwards you use
<XYZ:myClass> in your ASPX page.
Hope this helps
"Guillaume Hanique" <development@xxxxxxxxxxxxxxxxxx> wrote in message
news:OXs7GtZ0GHA.4796@xxxxxxxxxxxxxxxxxxxxxxx
Hi,
I feel very stupid. I simply want to derive a control from
system.web.ui.webcontrols.button and use that on my webform, but I just
can't get it done. Can anyone tell me how to do that?
I can create my own usercontrol (Menu: Website > Add new item... > Web
User Control). This creates an aspx and an aspx.vb file in the root
folder, which inherits nicely from system.web.ui.usercontrol. But I want
to inherit system.web.ui.webcontrols.button. I can't change anything in
this aspx and aspx.vb file to make it inherit from the button and make
it work.
The examples I found on the internet simply create a class and derive it
from the webcontrol. But no one says if the save it in the root folder
or in the App_Code folder. They use the <@ register tag to register it
and they fill the assembly and namespace attributes. I tried a lot, but
can't find anything I can put in the assembly and namespace attributes
that makes it work.
What steps do I take in VS 2005 to add a control that is derived from
system.web.ui.webcontrols.button to the solution and use it in my only
webform Default.aspx?
Thanks so much!
Guillaume Hanique
.
- Follow-Ups:
- Re: Howto inherit from an exisiting webcontrol in VS 2005
- From: Guillaume Hanique
- Re: Howto inherit from an exisiting webcontrol in VS 2005
- References:
- Howto inherit from an exisiting webcontrol in VS 2005
- From: Guillaume Hanique
- Howto inherit from an exisiting webcontrol in VS 2005
- Prev by Date: Re: USe SMTP to Send Mail
- Next by Date: Re: Howto inherit from an exisiting webcontrol in VS 2005
- Previous by thread: Howto inherit from an exisiting webcontrol in VS 2005
- Next by thread: Re: Howto inherit from an exisiting webcontrol in VS 2005
- Index(es):