473,327 Members | 1,892 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.

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.cs (base class):
----------------------------------------------------

public class SubNavControl : UserControl
{
//delegate for nav-button clicks
public delegate void NavItemClick(object sender, System.EventArgs
e);

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

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

public partial class SubNav : SubNavControl
{
protected void imgSection1_Click(object sender, ImageClickEventArgs
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.NavItemClicked(this, e);
}

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

thanks!
sm
Oct 3 '08 #1
0 923

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

Similar topics

1
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...
2
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...
4
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...
3
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...
3
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...
2
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...
1
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...
2
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...
2
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...
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...
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: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
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.