M
mauricio
Hi,
Sorry for my english.
I have a custom server control that derive from Panel.
In my control I want to add an Checkbox, but after an postback it
checkbox lost the state of checked property.
My code:
public class CheckboxPanel : System.Web.UI.WebControls.Panel,
IPostBackDataHandler
{
private CheckBox _chk = new CheckBox();
protected override void CreateChildControls()
{
_chk = new CheckBox();
_chk.ID = this.ClientID + "_chk";
}
public override void RenderBeginTag(HtmlTextWriter writer)
{
base.RenderBeginTag(writer);
writer.AddStyleAttribute(HtmlTextWriterStyle.Width,
"100%");
writer.RenderBeginTag(HtmlTextWriterTag.Table);
writer.RenderBeginTag(HtmlTextWriterTag.Tr);
writer.RenderBeginTag(HtmlTextWriterTag.Td);
_chk.RenderControl(writer);
writer.RenderEndTag(); // TD
writer.RenderEndTag(); // TR
writer.RenderBeginTag(HtmlTextWriterTag.Tr);
writer.RenderBeginTag(HtmlTextWriterTag.Td);
}
public override void RenderEndTag(HtmlTextWriter writer)
{
writer.RenderEndTag();
writer.RenderEndTag();
writer.RenderEndTag();
base.RenderEndTag(writer);
}
}
Sorry for my english.
I have a custom server control that derive from Panel.
In my control I want to add an Checkbox, but after an postback it
checkbox lost the state of checked property.
My code:
public class CheckboxPanel : System.Web.UI.WebControls.Panel,
IPostBackDataHandler
{
private CheckBox _chk = new CheckBox();
protected override void CreateChildControls()
{
_chk = new CheckBox();
_chk.ID = this.ClientID + "_chk";
}
public override void RenderBeginTag(HtmlTextWriter writer)
{
base.RenderBeginTag(writer);
writer.AddStyleAttribute(HtmlTextWriterStyle.Width,
"100%");
writer.RenderBeginTag(HtmlTextWriterTag.Table);
writer.RenderBeginTag(HtmlTextWriterTag.Tr);
writer.RenderBeginTag(HtmlTextWriterTag.Td);
_chk.RenderControl(writer);
writer.RenderEndTag(); // TD
writer.RenderEndTag(); // TR
writer.RenderBeginTag(HtmlTextWriterTag.Tr);
writer.RenderBeginTag(HtmlTextWriterTag.Td);
}
public override void RenderEndTag(HtmlTextWriter writer)
{
writer.RenderEndTag();
writer.RenderEndTag();
writer.RenderEndTag();
base.RenderEndTag(writer);
}
}