when i used VS Web Express, i created a custom user control .ascx
it doesn't allow to inherit other base classes than System.Web.UI.UserControl.

i have a base class called =>
public class PortalModuleControl : System.Web.UI.UserControl

Then i try to inherit my .ascx class to PortalModuleControl class.
public partial class MyControl : ASPNetPortal.PortalModuleControl


The compiler generate the following error:
Partial declarations of 'ASPNetPortal.MyControl' must not specify different
base classes

Anyone know why it doesn't work?

Re: User Controls in .NET Framework 2.0 Beta by Sahil

Sahil
Wed Oct 13 21:58:09 CDT 2004

Partial classes is a new feature in .NET framework 2.0. Basically it means
that you have two files which contain definition for the same class. i.e.
one class being split up into two or more files.

The reason it doesn't work here is, they UserControl stuff now works in a
code beside model rather than code behind model. So basically the ascx is a
class that inherits from UserControl, but you took the partial class (code
beside) and made it inherit from something else - therefore it won't work.

- Sahil Malik
You can reach me thru my blog http://www.dotnetjunkies.com/weblog/sahilmalik




"Heng Tan" <Heng Tan@discussions.microsoft.com> wrote in message
news:BB37B5E0-7334-4F55-9DDD-B9EA4B72BBB6@microsoft.com...
> when i used VS Web Express, i created a custom user control .ascx
> it doesn't allow to inherit other base classes than
> System.Web.UI.UserControl.
>
> i have a base class called =>
> public class PortalModuleControl : System.Web.UI.UserControl
>
> Then i try to inherit my .ascx class to PortalModuleControl class.
> public partial class MyControl : ASPNetPortal.PortalModuleControl
>
>
> The compiler generate the following error:
> Partial declarations of 'ASPNetPortal.MyControl' must not specify
> different
> base classes
>
> Anyone know why it doesn't work?
>
>
>



Re: User Controls in .NET Framework 2.0 Beta by HengTan

HengTan
Thu Oct 14 04:11:04 CDT 2004

hi Sahil,

Thanks for the reply. I have another question. The reason i code it this
way, is becuase i want each usercontrol i created to encapsulate the same
additional information.

for example:

public class PortalModuleControl : System.Web.UI.UserControl
{
int portalID;
}

public partial class MyControl : ASPNetPortal.PortalModuleControl

public partial class MyControl2 : ASPNetPortal.PortalModuleControl

In the above case, i don't need to explicitly define the portaID in both
MyControl
and MyControl2 class. Hence, i can create some function in my base class
PortalModuleControl and share among MyControl and MyControl2. Do you have
any suggestion that how i should go about this in .NET Framework 2.0?

"Sahil Malik" wrote:

> Partial classes is a new feature in .NET framework 2.0. Basically it means
> that you have two files which contain definition for the same class. i.e.
> one class being split up into two or more files.
>
> The reason it doesn't work here is, they UserControl stuff now works in a
> code beside model rather than code behind model. So basically the ascx is a
> class that inherits from UserControl, but you took the partial class (code
> beside) and made it inherit from something else - therefore it won't work.
>
> - Sahil Malik
> You can reach me thru my blog http://www.dotnetjunkies.com/weblog/sahilmalik
>
>
>
>
> "Heng Tan" <Heng Tan@discussions.microsoft.com> wrote in message
> news:BB37B5E0-7334-4F55-9DDD-B9EA4B72BBB6@microsoft.com...
> > when i used VS Web Express, i created a custom user control .ascx
> > it doesn't allow to inherit other base classes than
> > System.Web.UI.UserControl.
> >
> > i have a base class called =>
> > public class PortalModuleControl : System.Web.UI.UserControl
> >
> > Then i try to inherit my .ascx class to PortalModuleControl class.
> > public partial class MyControl : ASPNetPortal.PortalModuleControl
> >
> >
> > The compiler generate the following error:
> > Partial declarations of 'ASPNetPortal.MyControl' must not specify
> > different
> > base classes
> >
> > Anyone know why it doesn't work?
> >
> >
> >
>
>
>

Re: User Controls in .NET Framework 2.0 Beta by Sahil

Sahil
Thu Oct 14 09:57:32 CDT 2004

Heng,

The ascx front end supports a page directive called "INHERITS".

You would need to create a new class that inherits from
System.Web.UI.UserControl, put in this behavior there, and make sure both
your codebeside and ascx inherit from that custom class.

- Sahil Malik
You can reach me thru my blog at
http://www.dotnetjunkies.com/weblog/sahilmalik


"Heng Tan" <HengTan@discussions.microsoft.com> wrote in message
news:2ADC4121-EBF5-4E39-9CD5-B9B4B3754BE4@microsoft.com...
> hi Sahil,
>
> Thanks for the reply. I have another question. The reason i code it this
> way, is becuase i want each usercontrol i created to encapsulate the same
> additional information.
>
> for example:
>
> public class PortalModuleControl : System.Web.UI.UserControl
> {
> int portalID;
> }
>
> public partial class MyControl : ASPNetPortal.PortalModuleControl
>
> public partial class MyControl2 : ASPNetPortal.PortalModuleControl
>
> In the above case, i don't need to explicitly define the portaID in both
> MyControl
> and MyControl2 class. Hence, i can create some function in my base class
> PortalModuleControl and share among MyControl and MyControl2. Do you have
> any suggestion that how i should go about this in .NET Framework 2.0?
>
> "Sahil Malik" wrote:
>
> > Partial classes is a new feature in .NET framework 2.0. Basically it
means
> > that you have two files which contain definition for the same class.
i.e.
> > one class being split up into two or more files.
> >
> > The reason it doesn't work here is, they UserControl stuff now works in
a
> > code beside model rather than code behind model. So basically the ascx
is a
> > class that inherits from UserControl, but you took the partial class
(code
> > beside) and made it inherit from something else - therefore it won't
work.
> >
> > - Sahil Malik
> > You can reach me thru my blog
http://www.dotnetjunkies.com/weblog/sahilmalik
> >
> >
> >
> >
> > "Heng Tan" <Heng Tan@discussions.microsoft.com> wrote in message
> > news:BB37B5E0-7334-4F55-9DDD-B9EA4B72BBB6@microsoft.com...
> > > when i used VS Web Express, i created a custom user control .ascx
> > > it doesn't allow to inherit other base classes than
> > > System.Web.UI.UserControl.
> > >
> > > i have a base class called =>
> > > public class PortalModuleControl : System.Web.UI.UserControl
> > >
> > > Then i try to inherit my .ascx class to PortalModuleControl class.
> > > public partial class MyControl : ASPNetPortal.PortalModuleControl
> > >
> > >
> > > The compiler generate the following error:
> > > Partial declarations of 'ASPNetPortal.MyControl' must not specify
> > > different
> > > base classes
> > >
> > > Anyone know why it doesn't work?
> > >
> > >
> > >
> >
> >
> >