CheckBox control and IPostBackDataHandler

Discussion in 'ASP .Net' started by Francois, Dec 1, 2004.

  1. Francois

    Francois Guest

    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
     
    Francois, Dec 1, 2004
    #1
    1. Advertising

  2. Francois

    Joe Fallon Guest

    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" <_NOSPAM> wrote in message
    news:...
    > 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
    >
    >
    >
    >
     
    Joe Fallon, Dec 2, 2004
    #2
    1. Advertising

  3. Francois

    Francois Guest

    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" <> wrote in message
    news:uJVn1$...
    > 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" <_NOSPAM> wrote in message
    > news:...
    > > 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
    > >
    > >
    > >
    > >

    >
    >
     
    Francois, Dec 2, 2004
    #3
  4. Francois

    Joe Fallon Guest

    The samples in the book (I am 1/2 way through it) show that the controls
    being built are inheriting from Web Control and directly implementing the
    interface.


    I am sure you can inherit an existing control but I have not got to the part
    about the interface overrides.
    Sorry.
    --
    Joe Fallon



    "Francois" <_NOSPAM> wrote in message
    news:...
    > 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" <> wrote in message
    > news:uJVn1$...
    >> 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" <_NOSPAM> wrote in message
    >> news:...
    >> > 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
    >> >
    >> >
    >> >
    >> >

    >>
    >>

    >
    >
     
    Joe Fallon, Dec 3, 2004
    #4
  5. Francois

    Joe Fallon Guest

    BTW - I assumed you tried the code without the use of the word override.
    But that may have been a poor assumption.

    I believe C# allows you to simply re-implement the interface. (VB does not.)

    bool IPostBackDataHandler.LoadPostData( string postDataKey,
    NameValueCollection postCollection)
    --
    Joe Fallon



    "Joe Fallon" <> wrote in message
    news:eG3g%...
    > The samples in the book (I am 1/2 way through it) show that the controls
    > being built are inheriting from Web Control and directly implementing the
    > interface.
    >
    >
    > I am sure you can inherit an existing control but I have not got to the
    > part about the interface overrides.
    > Sorry.
    > --
    > Joe Fallon
    >
    >
    >
    > "Francois" <_NOSPAM> wrote in message
    > news:...
    >> 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" <> wrote in message
    >> news:uJVn1$...
    >>> 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" <_NOSPAM> wrote in message
    >>> news:...
    >>> > 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
    >>> >
    >>> >
    >>> >
    >>> >
    >>>
    >>>

    >>
    >>

    >
    >
     
    Joe Fallon, Dec 3, 2004
    #5
  6. Francois

    Francois Guest

    With or without the use of the keyword override it does not work.

    And yes i can easily extend checkbox and it all works well. the only things
    i cannot do is to override the methods of the interface
    IPostBackDataHandler. Which for me is nonsense as those methods must exist
    (as the base class implements the interface). If I can override the other
    methods why not those 2 ? Eventually, I could solve to problem in the
    following manner (see code hereunder), but I do not understand why. For me
    the override should work. And it would also be a cleaner way to do. This
    seems to me more like bypassing the implementation of the interface of the
    base class which sounds dangerous to me as it brings a possibilty to do it
    accidently.

    public class CheckBoxValue : System.Web.UI.WebControls.CheckBox,
    IPostBackDataHandler
    {

    protected override void OnCheckedChanged(EventArgs e)
    {
    // here i can override a method inherited from the base class
    }

    bool IPostBackDataHandler.LoadPostData(string postDataKey,
    NameValueCollection postCollection)
    {
    /* here i cannot override this method that the base class implements (as
    the base class also implement the interface IPostBackDataHandler. I have a
    to re implement the interface like if it was never implemented by the base
    class.
    */
    }

    void IPostBackDataHandler.RaisePostDataChangedEvent()
    {
    /* here i cannot override this method that the base class implements (as
    the base class also implement the interface IPostBackDataHandler. I have a
    to re implement the interface like if it was never implemented by the base
    class.
    */
    }

    }

    Francois.


    "Joe Fallon" <> wrote in message
    news:%...
    > BTW - I assumed you tried the code without the use of the word override.
    > But that may have been a poor assumption.
    >
    > I believe C# allows you to simply re-implement the interface. (VB does

    not.)
    >
    > bool IPostBackDataHandler.LoadPostData( string postDataKey,
    > NameValueCollection postCollection)
    > --
    > Joe Fallon
    >
    >
    >
    > "Joe Fallon" <> wrote in message
    > news:eG3g%...
    > > The samples in the book (I am 1/2 way through it) show that the controls
    > > being built are inheriting from Web Control and directly implementing

    the
    > > interface.
    > >
    > >
    > > I am sure you can inherit an existing control but I have not got to the
    > > part about the interface overrides.
    > > Sorry.
    > > --
    > > Joe Fallon
    > >
    > >
    > >
    > > "Francois" <_NOSPAM> wrote in message
    > > news:...
    > >> 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" <> wrote in message
    > >> news:uJVn1$...
    > >>> 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" <_NOSPAM> wrote in message
    > >>> news:...
    > >>> > 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
    > >>> >
    > >>> >
    > >>> >
    > >>> >
    > >>>
    > >>>
    > >>
    > >>

    > >
    > >

    >
    >
     
    Francois, Dec 3, 2004
    #6
  7. Francois

    Joe Fallon Guest

    Try it without IPostBackDataHandler at the top of the class.

    public class CheckBoxValue : System.Web.UI.WebControls.CheckBox
    /// IPostBackDataHandler

    The base class already implements it so you should not have to re-declare
    that you are implementing it.

    Then perhaps you should be able to use:
    bool IPostBackDataHandler.LoadPostData(string postDataKey,
    NameValueCollection postCollection)

    --
    Joe Fallon




    "Francois" <_NOSPAM> wrote in message
    news:...
    > With or without the use of the keyword override it does not work.
    >
    > And yes i can easily extend checkbox and it all works well. the only
    > things
    > i cannot do is to override the methods of the interface
    > IPostBackDataHandler. Which for me is nonsense as those methods must exist
    > (as the base class implements the interface). If I can override the other
    > methods why not those 2 ? Eventually, I could solve to problem in the
    > following manner (see code hereunder), but I do not understand why. For me
    > the override should work. And it would also be a cleaner way to do. This
    > seems to me more like bypassing the implementation of the interface of the
    > base class which sounds dangerous to me as it brings a possibilty to do it
    > accidently.
    >
    > public class CheckBoxValue : System.Web.UI.WebControls.CheckBox,
    > IPostBackDataHandler
    > {
    >
    > protected override void OnCheckedChanged(EventArgs e)
    > {
    > // here i can override a method inherited from the base class
    > }
    >
    > bool IPostBackDataHandler.LoadPostData(string postDataKey,
    > NameValueCollection postCollection)
    > {
    > /* here i cannot override this method that the base class implements (as
    > the base class also implement the interface IPostBackDataHandler. I have a
    > to re implement the interface like if it was never implemented by the base
    > class.
    > */
    > }
    >
    > void IPostBackDataHandler.RaisePostDataChangedEvent()
    > {
    > /* here i cannot override this method that the base class implements (as
    > the base class also implement the interface IPostBackDataHandler. I have a
    > to re implement the interface like if it was never implemented by the base
    > class.
    > */
    > }
    >
    > }
    >
    > Francois.
    >
    >
    > "Joe Fallon" <> wrote in message
    > news:%...
    >> BTW - I assumed you tried the code without the use of the word override.
    >> But that may have been a poor assumption.
    >>
    >> I believe C# allows you to simply re-implement the interface. (VB does

    > not.)
    >>
    >> bool IPostBackDataHandler.LoadPostData( string postDataKey,
    >> NameValueCollection postCollection)
    >> --
    >> Joe Fallon
    >>
    >>
    >>
    >> "Joe Fallon" <> wrote in message
    >> news:eG3g%...
    >> > The samples in the book (I am 1/2 way through it) show that the
    >> > controls
    >> > being built are inheriting from Web Control and directly implementing

    > the
    >> > interface.
    >> >
    >> >
    >> > I am sure you can inherit an existing control but I have not got to the
    >> > part about the interface overrides.
    >> > Sorry.
    >> > --
    >> > Joe Fallon
    >> >
    >> >
    >> >
    >> > "Francois" <_NOSPAM> wrote in message
    >> > news:...
    >> >> 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" <> wrote in message
    >> >> news:uJVn1$...
    >> >>> 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" <_NOSPAM> wrote in message
    >> >>> news:...
    >> >>> > 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
    >> >>> >
    >> >>> >
    >> >>> >
    >> >>> >
    >> >>>
    >> >>>
    >> >>
    >> >>
    >> >
    >> >

    >>
    >>

    >
    >
     
    Joe Fallon, Dec 5, 2004
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Showjumper

    Re: Help w/ IPostBackDataHandler

    Showjumper, Jun 24, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    1,642
    Showjumper
    Jun 24, 2003
  2. One Handed Man \( OHM - Terry Burns \)

    Custom Control & System.Web.UI.IPostBackDataHandler.LoadPostData

    One Handed Man \( OHM - Terry Burns \), Jun 17, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    1,942
    One Handed Man \( OHM - Terry Burns \)
    Jun 17, 2004
  3. =?Utf-8?B?YnJpYW4ubWlsbHM=?=

    IPostBackDataHandler.LoadPostData

    =?Utf-8?B?YnJpYW4ubWlsbHM=?=, Apr 20, 2005, in forum: ASP .Net
    Replies:
    6
    Views:
    3,434
    William F. Robertson, Jr.
    Apr 25, 2005
  4. z f
    Replies:
    1
    Views:
    8,222
    =?Utf-8?B?RFdT?=
    Mar 1, 2006
  5. Andrew Dawson

    Implementing IPostBackDataHandler in a custom web control with VB.NET

    Andrew Dawson, Aug 9, 2004, in forum: ASP .Net Building Controls
    Replies:
    1
    Views:
    418
    Teemu Keiski
    Aug 12, 2004
Loading...

Share This Page