P
Paul L
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,
Level83.IEditableControl
{
protected override void Render(HtmlTextWriter output)
{
output.Write("TEST TEST TEST");
base.Render(output);
}
protected override void AddAttributesToRender(HtmlTextWriter writer)
{
writer.AddAttribute(HtmlTextWriterAttribute.Onclick,
"alert('Hello');");
base.AddAttributesToRender (writer);
}
....
...
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,
Level83.IEditableControl
{
protected override void Render(HtmlTextWriter output)
{
output.Write("TEST TEST TEST");
base.Render(output);
}
protected override void AddAttributesToRender(HtmlTextWriter writer)
{
writer.AddAttribute(HtmlTextWriterAttribute.Onclick,
"alert('Hello');");
base.AddAttributesToRender (writer);
}
....
...