Dynamic AJAX CheckBox creation problem..

Joined
Oct 2, 2007
Messages
2
Reaction score
0
Hello,

I'm trying to create dynamically an Anthem:CheckBox, in my site.
It progresses like this:
1) You click on existed button and the Click method of it is called and creates a table with an AJAX CheckBox in it (That needs also to fire an event when checked changed). Ok, now saved it in a Session 'cause when the Page_Load is called again after a PostBack I want it to read this Session again so I won't loose the table I created.
2) When I click the AJAX CheckBox I created dynamically (in the table I created dynamically too), i want to save its status in its CheckedChanged method (whether it's Checked or not) that when the Page_Load is called again, I won't loose its new status.

The problem that the event CheckedChanged isn't firing when I change the status of the dynamically AJAX CheckBox. Why isn't it firing?

BTW here's the code:

The ASPX code:
Code:
<anthem:Table ID="tblPageLayout" runat="server"></anthem:Table>
<anthem:Button ID="btnGenerateTable" runat="server" Text="Create table" OnClick="btnGenerateTable_Click" />
<anthem:Button ID="Button1" runat="server" Text="Get checkbox status" OnClick="Button1_Click" />
<anthem:Label ID="lbl" runat="server"></anthem:Label>
<anthem:CheckBox ID="cbTest" runat="server" OnCheckedChanged="CheckBox_CheckedChanged" AutoCallBack="true"  />

The code behind:
Code:
protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["table"] != null)
            tblPageLayout = (Anthem.Table)Session["table"];
    }

    protected void btnGenerateTable_Click(object sender, EventArgs e)
    {
        TableRow tr = new TableRow();
        TableCell td = new TableCell();
        Anthem.CheckBox cb = new Anthem.CheckBox();
        cb.ID = "cb";
        cb.AutoCallBack = true;
        cb.CheckedChanged += new EventHandler(CheckBox_CheckedChanged);
        td.Controls.Add(cb);
        tr.Cells.Add(td);

        tblPageLayout.Rows.Add(tr);
        tblPageLayout.UpdateAfterCallBack = true;
        Session["table"] = tblPageLayout;
    }

    protected void Button1_Click(object sender, EventArgs e)
    {
        Anthem.CheckBox cb = (Anthem.CheckBox)tblPageLayout.Rows[0].Cells[0].FindControl("cb");
        lbl.Text = cb.Checked.ToString();
        lbl.UpdateAfterCallBack = true;
    }

    protected void CheckBox_CheckedChanged(object sender, EventArgs e)
    {
        //Saves the CheckBox status
    }

Thanks for the helpers :top:

Ben Livnat
MCSD .NET
 
Last edited:

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top