Custom CheckBox class not calling AddAttributesToRender

Discussion in 'ASP .Net Building Controls' started by Paul L, Mar 17, 2005.

  1. Paul L

    Paul L Guest

    I have created a very simple WebControl which derives from the standard
    CheckBox control. I want to add an extra onclick attribute which will set a
    modified flag whenever the control's state changes. However the
    AddAttributesToRender doesn't seem to be called, which is very odd because
    it works fine for the TextBox I have overriden.

    The control is definitely being instantiated, and rendered, as my test
    output is there, and I can stick a breakpoint in the Render method, but when
    I stick a breakpoint in the AddAttributesToRender method I get nothing.

    Any ideas? The class source is below:

    [ToolboxData("<{0}:CheckBox runat=server></{0}:CheckBox>")]
    public class CheckBox : System.Web.UI.WebControls.CheckBox,
    protected override void Render(HtmlTextWriter output)
    output.Write("TEST TEST TEST");

    protected override void AddAttributesToRender(HtmlTextWriter writer)
    base.AddAttributesToRender (writer);

    Paul L, Mar 17, 2005
    1. Advertisements

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.