Re: CheckBox control and IPostBackDataHandler

From: Francois (francois_at_bettinghouses.com_NOSPAM)
Date: 12/02/04


Date: Thu, 2 Dec 2004 13:50:35 -0000

Hi Joe,

Thanks for your help but that code does not compile neither and says that:
" The modifier 'override' is not valid for this item "

It seems that somehow i cannot override the interface
IPostBackDataHandler.LoadPostData method implemented by the base class.

I think I may not understand well enough inheritance and interface
implementation in C#. But I am pretty sure than in Java this would work.
Then maybe the problem is not related with the ASP.NET control but rather
with my pure C# skills. Any information on how to get up to speed on that
side? any good links in your Favorites? ;)

Thanks a lot,
Francois.

"Joe Fallon" <jfallon1@nospamtwcny.rr.com> wrote in message
news:uJVn1$C2EHA.3368@TK2MSFTNGP10.phx.gbl...
> I recommend you get the book "ASP.Net Server Controls and Components" by
> Kothari and Datye.
>
> You might want to try some code like this:
>
> override bool IPostBackDataHandler.LoadPostData( string postDataKey,
> NameValueCollection postCollection)
>
> I think you are not allowed to us Public, Private, Protected on Interface
> methods.
> You also have to prefix the method with the Interface name.
>
> Please let me know if that works for you.
> --
> Joe Fallon
>
>
>
>
> "Francois" <francois@bettinghouses.com_NOSPAM> wrote in message
> news:uqWiPy11EHA.3500@TK2MSFTNGP09.phx.gbl...
> > Hi,
> >
> > I am trying to implement a custom control that extends the standard
> > System.Web.UI.WebControls.CheckBox control. In the .Net class library
> > reference it is said that CheckBox Implements IPostBackDataHandler
> > interface. I want to override the 2 methods defined by that interface
but
> > i
> > do not see in the CheckBox class that the methods of
IPostBackDataHandler
> > are implemented. But they should be as the class is said to implement
the
> > interface.
> > The 2 methods defined by IPostBackDataHandler are:
> > - RaisePostDataChangedEvent
> > - LoadPostData
> >
> > Then how cam I create a custom control that extends CheckBox and
overrides
> > RaisePostDataChangedEven and LoadPostData?
> >
> > I tried to following code but it does not compile, it says the
> > CheckBoxValue.cs: 'Bos.CustomControls.CheckBoxValue.LoadPostData(string,
> > System.Collections.Specialized.NameValueCollection)': no suitable method
> > found to override
> >
> > using System;
> > using System.Collections;
> > using System.Collections.Specialized;
> > using System.Web.UI;
> > using System.Web.UI.WebControls;
> > using System.ComponentModel;
> >
> > namespace Bos.CustomControls
> > {
> >
> > public class CheckBoxValue : System.Web.UI.WebControls.CheckBox
> > {
> >
> > private bool isChanged = false;
> >
> > public CheckBoxValue()
> > {
> > }
> >
> > public bool IsChanged
> > {
> > get
> > {
> > return this.isChanged;
> > }
> > set
> > {
> > this.isChanged = value;
> > }
> > }
> >
> > protected override void OnCheckedChanged(EventArgs e)
> > {
> > IsChanged = true;
> > base.OnCheckedChanged(e);
> > }
> >
> > protected override bool LoadPostData( string postDataKey,
> > NameValueCollection postCollection)
> > {
> > }
> >
> > }
> > }
> >
> > Best regards,
> >
> > Francois
> >
> >
> >
> >
>
>



Relevant Pages

  • Re: I dont understand inheritance!
    ... Look up explicit interface implementation to answer the majority of your ... which your subclasses can override. ... > //this does not compile, compiler says: ... > /* here i cannot override this method that the base class implements ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: I dont understand inheritance!
    ... you can't override Interface methods that aren't marked as ... public abstract void DoSomething(); ... > IPostBackDataHandler (notice the interface that is implemented) ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: I dont understand inheritance!
    ... you can't override Interface methods that aren't marked as ... public abstract void DoSomething(); ... > IPostBackDataHandler (notice the interface that is implemented) ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Deriving - .NET example
    ... that existing interface will be supported in the future versions, ... If the class had a small interface, I wouldn't think twice - the inheritance approach would not seem appropriate. ... Of course I would not choose the approach to code and not to use designer. ... If I need to override, ...
    (comp.object)
  • Re: Discussion: "Why Visual Studion 2005 is better then BDS 2006?"
    ... This should put in the declarations. ... interface and every method I could override. ... The BDS code templates are also context sensitive. ...
    (borland.public.delphi.non-technical)