473,761 Members | 5,848 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

problem while inheriting a UserControl base

hello,

i am working on a web application w/ UserControls. some of my controls
use the same functionality (an Event they all raise) so it seemed
sensible to place them into a custom base class, and have my
UserControls inherit it.

problem is, when i do this the im no longer able to raise the event in
deriving UserControls. it fails to compile, saying:

The event 'SubNavControl. NavItemClicked' can only appear on the left
hand side of += or -= (except when used from within the type
'SubNavControl' )

the code:

SubNavControl.c s (base class):
----------------------------------------------------

public class SubNavControl : UserControl
{
//delegate for nav-button clicks
public delegate void NavItemClick(ob ject sender, System.EventArg s
e);

//event for the same
public event NavItemClick NavItemClicked;
}

SubNav.ascx.cs (deriving class):
----------------------------------------------------

public partial class SubNav : SubNavControl
{
protected void imgSection1_Cli ck(object sender, ImageClickEvent Args
e)
{
//raise the event defined in base -- FAILS. works if delegate/
event
//is local only, not if in the base (see error message above)
base.NavItemCli cked(this, e);
}

}
....whats up? doing something wrong?

thanks!
sm
Oct 3 '08 #1
0 937

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

Similar topics

1
1532
by: Boniek | last post by:
Hi Sometimes I have problems with my forms which are inherited from other forms and base forms are in other project. When I change something in base forms my normal forms are broken in Visual in designing. Maybe inherited forms aren't compatible with base forms but I don't know how and what. I compile all projects and everything is ok. When I open one form I see a message like that "Member not found". I don't know what member and where...
2
1485
by: Charles Law | last post by:
I have a base class - ComponentBase - that inherits from UserControl. My class implements IComponentBase, which defines a minimal set of core properties and methods. All my other components inherit from ComponentBase. I have defined IComponentBase in a common assembly so that my other projects reference this rather than the (large) library that contains the component implementation.
4
1199
by: elziko | last post by:
I would like to do the following: Create a class that inherits from a usercontrol. Then add a control to the designer Call this new class ClassA. Many controls I need will start off like this so I'd like to create all controls form now on from this base control. So, for example, I inherit from this base control and add the further controls required to form this part of my UI. Call this ClassB
3
1142
by: guy | last post by:
I have a problem with a class hierarchy. The inheriting and inherited class are in different solutions. In the base class, (which inherits from System.Windows.Forms.UserControl) i have a method Test, see below, and in the class which inherits from it i have a call to a method, Testx, which in turn calls Test.
3
1527
by: YYZ | last post by:
I swear I've done my research, and now I was just hoping someone could explain this to me. I've got a base class (usercontrol) that I am using just as an interface. Meaning, I've defined several MustOverride subs in there, and also a public property. I'm going to inherit a bunch of usercontrols from this one superclass (terminology correct?) and then they all have to make sure they can respond to that set of functions that I've...
2
1406
by: TJO | last post by:
I am having difficulty understanding why I cannot access my base .ascx class members from my inherited class. I create a base .ascx control and add a method. public partial class myWebControlBase : System.Web.UI.UserControl { public virtual void _foo(){ } }
1
1742
by: =?Utf-8?B?a2Fu?= | last post by:
hi, Consider i have built a UserControl say 'ColorMixer' in proj 'Step1'(Windows Control Proj). Now when create another proj 'Step2' as Windows Control and try adding 'ColorMixer' as inherited ctrl to create new 'ColorMixerX' ,following problem arises. Above process completes successfully,but when i try to bring up the Designer for newly created 'ColorMixerX' the Designer show following err msg : "An error occured while loading the...
2
2981
by: =?Utf-8?B?UmVuYXVkIExhbmdpcw==?= | last post by:
Hello, I have an asp.net web page (say page.aspx) which derives from a custom base page object (CustomPage : BasePage : System.Web.UI.Page) Which has a method called DoSomething(params). My web page contains a UserControl (say Control.ascx). In the control class, i want to call the DoSomething method. I cannot use type cast since in fact the base class Page structure is a little more complex (see bottom of post). Hence i cannot do:
2
1295
by: Charlie Brown | last post by:
I have two classes, one that inherits from UserControl called Base. I have a second class that inherits from Base. I do not want to expose a lot of the properties of usercontrol beyond the Base control. For example, lets say I want every control that inherits from Base to have a RED background and not be able to change it. Currently, backgroundcolor is available in the designer as a color choice. Can I change the scope of something to...
0
9522
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9336
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10111
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9948
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
7327
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6603
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5364
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3446
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2738
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.