Last post Oct 20, 2010 05:59 PM by jkirkerx
Oct 15, 2010 07:20 AM|cnu.jettiboyina|LINK
Iam developing a custom checkbox control deriving from the 'compositecontrol' which i need to use it for a composite control purpose.
i have written the required properties which are working fine except the "checked" property. here is my code for 'checked' property. i tried both the below ways (commented one and not commneted) . the problem is the 'checked' value is not setting the value
at the get set part of the property.its assigning the value at the design time , but when i check and uncheck its not updating the property value.which is resulting me wrong . can you plese help me on this ?
//private bool _checked;
//public bool Checked
// return _internalControl.Checked;
// _internalControl.Checked = value;
/// Gets or sets whether the checkbox is checked or not.
/// A System.Boolean value indication value indication true/false. Default value is false.
[DefaultValue(false), Bindable(true, BindingDirection.TwoWay), Themeable(false)]
public virtual bool Checked
object obj2 = this.ViewState["Checked"];
return ((obj2 != null) && ((bool)obj2));
this.ViewState["Checked"] = value;
Thanks & Regards,
Oct 15, 2010 08:59 AM|shashankgwl|LINK
what've you done in your render part? post the render method's code.
Oct 15, 2010 10:05 AM|cnu.jettiboyina|LINK
Hello shashank ,
Thanks for the response. My custom control is not having a render part. the composite control which i am deriving from will take care of that . correct me if iam wrong because iam new to this control dev. but when i use this checkbox its working absolutely
Thanks & regards,
Oct 15, 2010 12:53 PM|shashankgwl|LINK
very strange that you don't have render method overridden. How are u making it appear as a checkbox on the page.
There must be some HTML rendering part which will render the controls as <input type='radio'/>
Oct 20, 2010 05:59 PM|jkirkerx|LINK
Checkboxes are a boolean value, true or false, and in sql a bit which is 0 or 1.
In a control, you have to create the checkbox object. then in onLoad, set the checkbox value to true or false
If the page is postback, then the value of the checkbox will transmit back to the server, and come backset to the same value unless you changed it in OnLoad
So when you load values,
If Not Page.IsPostback
and when you transmit values, if Page.IsPostback