Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > CheckBox control and IPostBackDataHandler

Reply
Thread Tools

CheckBox control and IPostBackDataHandler

 
 
Francois
Guest
Posts: n/a
 
      12-01-2004
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(str ing,
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




 
Reply With Quote
 
 
 
 
Joe Fallon
Guest
Posts: n/a
 
      12-02-2004
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" <(E-Mail Removed)_NOSPAM> wrote in message
news:(E-Mail Removed)...
> 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(str ing,
> 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
>
>
>
>



 
Reply With Quote
 
 
 
 
Francois
Guest
Posts: n/a
 
      12-02-2004
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" <(E-Mail Removed)> wrote in message
news:uJVn1$(E-Mail Removed)...
> 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" <(E-Mail Removed)_NOSPAM> wrote in message
> news:(E-Mail Removed)...
> > 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(str ing,
> > 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
> >
> >
> >
> >

>
>



 
Reply With Quote
 
Joe Fallon
Guest
Posts: n/a
 
      12-03-2004
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" <(E-Mail Removed)_NOSPAM> wrote in message
news:(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
> news:uJVn1$(E-Mail Removed)...
>> 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" <(E-Mail Removed)_NOSPAM> wrote in message
>> news:(E-Mail Removed)...
>> > 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(str ing,
>> > 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
>> >
>> >
>> >
>> >

>>
>>

>
>



 
Reply With Quote
 
Joe Fallon
Guest
Posts: n/a
 
      12-03-2004
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" <(E-Mail Removed)> wrote in message
news:eG3g%(E-Mail Removed)...
> 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" <(E-Mail Removed)_NOSPAM> wrote in message
> news:(E-Mail Removed)...
>> 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" <(E-Mail Removed)> wrote in message
>> news:uJVn1$(E-Mail Removed)...
>>> 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" <(E-Mail Removed)_NOSPAM> wrote in message
>>> news:(E-Mail Removed)...
>>> > 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(str ing,
>>> > 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
>>> >
>>> >
>>> >
>>> >
>>>
>>>

>>
>>

>
>



 
Reply With Quote
 
Francois
Guest
Posts: n/a
 
      12-03-2004
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" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
> news:eG3g%(E-Mail Removed)...
> > 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" <(E-Mail Removed)_NOSPAM> wrote in message
> > news:(E-Mail Removed)...
> >> 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" <(E-Mail Removed)> wrote in message
> >> news:uJVn1$(E-Mail Removed)...
> >>> 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" <(E-Mail Removed)_NOSPAM> wrote in message
> >>> news:(E-Mail Removed)...
> >>> > 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(str ing,
> >>> > 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
> >>> >
> >>> >
> >>> >
> >>> >
> >>>
> >>>
> >>
> >>

> >
> >

>
>



 
Reply With Quote
 
Joe Fallon
Guest
Posts: n/a
 
      12-05-2004
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" <(E-Mail Removed)_NOSPAM> wrote in message
news:(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
> news:%(E-Mail Removed)...
>> 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" <(E-Mail Removed)> wrote in message
>> news:eG3g%(E-Mail Removed)...
>> > 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" <(E-Mail Removed)_NOSPAM> wrote in message
>> > news:(E-Mail Removed)...
>> >> 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" <(E-Mail Removed)> wrote in message
>> >> news:uJVn1$(E-Mail Removed)...
>> >>> 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" <(E-Mail Removed)_NOSPAM> wrote in message
>> >>> news:(E-Mail Removed)...
>> >>> > 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(str ing,
>> >>> > 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
>> >>> >
>> >>> >
>> >>> >
>> >>> >
>> >>>
>> >>>
>> >>
>> >>
>> >
>> >

>>
>>

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
a custom control in VB.NET that inherits from TextBox and from IPostBackDataHandler.... z f ASP .Net 1 03-01-2006 01:31 PM
IPostBackDataHandler.LoadPostData =?Utf-8?B?YnJpYW4ubWlsbHM=?= ASP .Net 6 04-25-2005 03:30 PM
Implementing IPostBackDataHandler in a custom web control with VB.NET Andrew Dawson ASP .Net Building Controls 1 08-12-2004 06:34 PM
Custom Control & System.Web.UI.IPostBackDataHandler.LoadPostData One Handed Man \( OHM - Terry Burns \) ASP .Net 1 06-17-2004 06:07 PM
Re: Help w/ IPostBackDataHandler Showjumper ASP .Net 0 06-24-2003 12:22 PM



Advertisments