Re: CheckBox control and IPostBackDataHandler

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Joe Fallon (jfallon1_at_nospamtwcny.rr.com)
Date: 12/02/04


Date: Thu, 2 Dec 2004 00:29:57 -0500

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: Change box color on checkbox control
    ... If you don't really need a checkbox but rather something that looks like ... Override the control's paint procedure. ... It may be best to just make a new control. ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Change box color on checkbox control
    ... Either implement your own wrapper for the Win32 Common Control.. ... Derive a new control from checkbox.. ... Override the control's paint procedure. ...
    (microsoft.public.dotnet.languages.vb)
  • Re: ValidationControl evaluationfunction ASP.NET 2.0
    ... If I don't call the validator base.AddAttributesToRender then no aspect ... Or are you suggesting that my override that does not call the base ... the output stream to render HTML content on the client. ... /// The control whose style should be changed when validation results ...
    (microsoft.public.dotnet.framework.aspnet.webcontrols)
  • Re: Strange painting problems
    ... why it works when I inherit from Button rather than UserControl or Control, ... one-liner OnPaint override seems to be troublesome. ... OnPaintBackground), no other custom painting] ...
    (microsoft.public.dotnet.framework.windowsforms)
  • Re: Urgent Q: correct coding of a Webcontrol Designer driving me nuts...
    ... its not that it is not correctly processing CLASS versus inline CSS rules -- ... That seemed to do it so that it continued to render as before in the ... Browser...and now immediately rebuilt/repainted the control in the IDE upon ... > for, and when to override it without mucking up the ViewState, but I also ...
    (microsoft.public.dotnet.framework.aspnet.webcontrols)