Menu

#155 CheckboxList looses state inside Anthem Table.Visible=false

open
nobody
None
7
2010-09-30
2010-09-29
Anonymous
No

.Net 1.1 :
Anthem 1.5.3

It seems that Checkboxlist selected items are not persisted when you put your checkboxlois inside an anthem table, and set it visible=false, then visible=true.

Simple print sreen attached to show the problem.

Code :
protected System.Web.UI.WebControls.Button HideTables;
protected Anthem.Table Table1;
protected System.Web.UI.WebControls.Table Table2;
protected System.Web.UI.WebControls.Button ShowTables;

override protected void OnInit(EventArgs e)
{
....
TableRow tr=new TableRow();
TableCell tc=new TableCell();
tr.Controls.Add(tc);
Table1.Rows.Add(tr);
CheckBoxList cbx=new CheckBoxList();
cbx.Items.Add(new ListItem("Test1","test1"));
cbx.Items.Add(new ListItem("Test2","test2"));
tc.Controls.Add(cbx);

TableRow tr2=new TableRow();
TableCell tc2=new TableCell();
tr2.Controls.Add(tc2);
Table2.Rows.Add(tr2);
CheckBoxList cbx2=new CheckBoxList();
cbx2.Items.Add(new ListItem("Test1","test1"));
cbx2.Items.Add(new ListItem("Test2","test2"));
tc2.Controls.Add(cbx2);
....
}

private void HideTables_Click(object sender, System.EventArgs e)
{
Table1.Visible=false;
Table2.Visible=false;
}

private void ShowTables_Click(object sender, System.EventArgs e)
{
Table1.Visible=true;
Table2.Visible=true;
}

Discussion

  • Anonymous

    Anonymous - 2010-09-30

    Ok, i figured out where this bug came from.

    Just change modify files Table.cs, Panel.cs, PlaceHolder.cs, DataGrid.cs, DataList.cs with a base.Visible = value in the overrided's Set :

    public override bool Visible
    {
    get
    {
    #if !V2
    bool DesignMode = this.Context == null;
    #endif
    return Anthem.Manager.GetControlVisible(this, ViewState, DesignMode);
    }
    set
    {
    Anthem.Manager.SetControlVisible(ViewState, value);
    base.Visible=value; // <----- Add THIS!
    }
    }

     

Log in to post a comment.