473,327 Members | 1,979 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

Inheritance problem

Hi all,

I am trying to write a user control. On this control, I just have
linkbuttons.

The codebehind has to inherit from my baseclass which inherits from
usercontrol.

e.g.

mypage.ascx inherits from mypage.ascx.cs
mypage.ascx.cs inherits from mybaseclass
mybaseclass inherits from system.web.ui.usercontrol

What I want to do is to allow people to use overrides in the usercontrol
while keeping the mybaseclass safe. I have seen this done before but I am
having problems. While the scenario above appears to be working so far, what
I now need to do is to manipulate the linkbuttons from mybaseclass, however,
I am having problems with it.

What I don't want to do is to type any more code into the mypage.ascx.cs. It
all has to happen from mybaseclass.

How do I do this? I have tried a number of things, such as findcontrol, I
have even declared the linkbuttons in the base class, all to no avail.

Thanks for any help you can give.

Best regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Local franchises available
Oct 7 '06 #1
2 1174
What you should do is express the problem you see with having the classes
"open" for other developers to alter, as I am not sure I fully understand
the problem. As long as the controls leave things in the base class, the
base class method will be used. If the person overrides a behavior, it will
no longer come from the base class unless the person explicitly calls down
the stack.

It sounds, to me, like you want the ability to do this

protected override void LinkButton1Message(string message)

And not call the base LinkButton1Message, but still have the message hook
up? If so, you are never going to achieve this. The norm is ...

base.LinkButton1Message = message

If you do not override, you can access directly, but you cannot do it if you
override and do not call the base method.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
http://gregorybeamer.spaces.live.com/

*************************************************
Think Outside the Box!
*************************************************
"David" <da*****************@revilloc.REMOVETHIS.comwrot e in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
Hi all,

I am trying to write a user control. On this control, I just have
linkbuttons.

The codebehind has to inherit from my baseclass which inherits from
usercontrol.

e.g.

mypage.ascx inherits from mypage.ascx.cs
mypage.ascx.cs inherits from mybaseclass
mybaseclass inherits from system.web.ui.usercontrol

What I want to do is to allow people to use overrides in the usercontrol
while keeping the mybaseclass safe. I have seen this done before but I am
having problems. While the scenario above appears to be working so far,
what I now need to do is to manipulate the linkbuttons from mybaseclass,
however, I am having problems with it.

What I don't want to do is to type any more code into the mypage.ascx.cs.
It all has to happen from mybaseclass.

How do I do this? I have tried a number of things, such as findcontrol, I
have even declared the linkbuttons in the base class, all to no avail.

Thanks for any help you can give.

Best regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Local franchises available

Oct 7 '06 #2
Hi,

(Sorry, I replied to you, not the group. My apologies. Here it is again for
the group.)

Maybe with an example....

Say I am developing a search interface but I don't want the developers down
the line to know how the search routines work. I create the user control
that the developers can drop onto their page. I want them to be able to
style/design the interface as tehy see fit, plus also to have codebehind
that they can manipulate the interface controls themself, such as make
links, textboxes etc visible.

So, there is a button event. I can bubble the event up and this works.
However, that button event does manipulation to the interface, such as allow
a datalist to appear or hide or show labels. This has to happen at the base
class level.

I could potentially write all the controls on the ascx as derived controls
that react accordingly, but that is likely to be heavy in coding, whereas if
I can manipulate the controls from my base class would make it so much
easier.

Any help would be much appreciated, even if it is to say it cannot be done
and to look at the alternative route (ideas for alternative routes would be
very welcome as well).

Best regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Local franchises available
"Cowboy (Gregory A. Beamer)" <No************@comcast.netNoSpamMwrote in
message news:ed**************@TK2MSFTNGP04.phx.gbl...
What you should do is express the problem you see with having the classes
"open" for other developers to alter, as I am not sure I fully understand
the problem. As long as the controls leave things in the base class, the
base class method will be used. If the person overrides a behavior, it
will no longer come from the base class unless the person explicitly calls
down the stack.

It sounds, to me, like you want the ability to do this

protected override void LinkButton1Message(string message)

And not call the base LinkButton1Message, but still have the message hook
up? If so, you are never going to achieve this. The norm is ...

base.LinkButton1Message = message

If you do not override, you can access directly, but you cannot do it if
you override and do not call the base method.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
http://gregorybeamer.spaces.live.com/

*************************************************
Think Outside the Box!
*************************************************
"David" <da*****************@revilloc.REMOVETHIS.comwrot e in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
>Hi all,

I am trying to write a user control. On this control, I just have
linkbuttons.

The codebehind has to inherit from my baseclass which inherits from
usercontrol.

e.g.

mypage.ascx inherits from mypage.ascx.cs
mypage.ascx.cs inherits from mybaseclass
mybaseclass inherits from system.web.ui.usercontrol

What I want to do is to allow people to use overrides in the usercontrol
while keeping the mybaseclass safe. I have seen this done before but I am
having problems. While the scenario above appears to be working so far,
what I now need to do is to manipulate the linkbuttons from mybaseclass,
however, I am having problems with it.

What I don't want to do is to type any more code into the mypage.ascx.cs.
It all has to happen from mybaseclass.

How do I do this? I have tried a number of things, such as findcontrol, I
have even declared the linkbuttons in the base class, all to no avail.

Thanks for any help you can give.

Best regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Local franchises available


Oct 7 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: AIM | last post by:
Error in msvc in building inheritance.obj to build hello.pyd Hello, I am trying to build the boost 1.31.0 sample extension hello.cpp. I can not compile the file inheritance.cpp because the two...
3
by: Morten Aune Lyrstad | last post by:
Hi again! I'm having problems with inheritance. I have a base interface class called IObject. Next I have two other interfaces classes, IControl and ICommandMaster, which derives from IObject. ...
14
by: Steve Jorgensen | last post by:
Recently, I tried and did a poor job explaining an idea I've had for handling a particular case of implementation inheritance that would be easy and obvious in a fully OOP language, but is not at...
22
by: Matthew Louden | last post by:
I want to know why C# doesnt support multiple inheritance? But why we can inherit multiple interfaces instead? I know this is the rule, but I dont understand why. Can anyone give me some concrete...
8
by: Gaetan | last post by:
hi i have 2 classes A1 and A2 implementing a problem with 2 different ways i also have 2 other classes X1 and X2 implementing an other problem i need classes that provide A1+X1 methods,...
6
by: VR | last post by:
Hi, I read about Master Pages in ASP.Net 2.0 and after implementing some WinForms Visual Inheritance I tryed it with WebForms (let's say .aspx pages, my MasterPage does not have a form tag itself...
60
by: Shawnk | last post by:
Some Sr. colleges and I have had an on going discussion relative to when and if C# will ever support 'true' multiple inheritance. Relevant to this, I wanted to query the C# community (the...
5
by: colint | last post by:
Hi I'm fairly new to c++ and I have a question regarding inheritance. I'm trying to create a class based on 2 inherited classes, e.g. class A { ... } class B: public A
5
by: a | last post by:
Hi, I have an oop inheritance graph problem. What is the difference betweent the following 2 inheritance graph? How does the C++ solve the naming conflict problem for multiple inheritance...
3
by: Leo Seccia | last post by:
Hello everyone, I have a c# project with a sql server database. I have a number of lookup tables in my database which I successfully managed to import into my LINQ dataclasses. eg. Table:...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.