I have an asp page where controls are dynamically added from the DB on Page_Init() The EnableViewState is set to false.
One of the dynamic controls is a CheckBox and when checked it causes postback.
Now on Page_Init I repopulate my page (after changing according to rules) and the checkbox's checked property is now false.
It stays false up to the end of LoadPageStateFromPersistenceMedium() from what I can see.
protected override object LoadPageStateFromPersistenceMedium()
{
Control cntrl = Page.FindControl("FINS10CopyAddress");
Boolean check = ((CheckBox)cntrl).Checked;
return null;
}
Then suddenly its true again on OnPreLoad().
protected override void OnPreLoad(EventArgs e)
{
Control cntrl = Page.FindControl("FINS10CopyAddress");
Boolean check = ((CheckBox)cntrl).Checked;
}
If I do the same with another control's visible property it works.
Any ideas what can cause this or suggested methods to override to not load previous state ?
The Answer below helped me to create a workaround:
dataValue cntrl = ((Helper)Session["helper"]).Event.Control(Request["__EVENTTARGET"]);
if (cntrl != null)
{
if (cntrl is webCheckBox)
((CheckBox)Page.FindControl(Request["__EVENTTARGET"])).Checked = (Boolean)cntrl.Value;
}