Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

problem while inheriting a UserControl base

0 views
Skip to first unread message

SpaceMarine

unread,
Oct 3, 2008, 2:57:44 PM10/3/08
to
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 to
make sense 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
the deriving UserControls. it fails to compile, saying:

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

...


SubNavControl.cs (base class):


namespace CNO.NOPD.EPR.Bases
{
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 : Bases.SubNavControl
{
protected void imgSection1_Click(object sender, ImageClickEventArgs
e)
{
//used by consuming page
this.RedirectUrl = "~/facesheet/Event.aspx";

//raise the event defined in base -- FAILS. works if delegate/event
is local only, not if in the base
base.NavItemClicked(this, e);
}
}

...whats up? doing something wrong?

thanks!
sm

SpaceMarine

unread,
Oct 3, 2008, 3:14:21 PM10/3/08
to
On Oct 3, 1:57 pm, SpaceMarine <spacemar...@mailinator.com> wrote:
> ...whats up? doing something wrong?

btw there is a naming error in the above, but only because i was
"cleaning" the namespaces for the code snippit and missed one. its not
that.


sm

0 new messages