views:

82

answers:

1

i have radio buttons that autopostback and set panels to either visible or invisible. The entire page is in an update panel so that i can force it to update and show the invisible changes. The radio buttons are also in update panels.

It works fine except for one thing - my javascript went out the window! It can't find any of my controls after the panel is updated.

Is there some way i can fix this?

 Panel PnlPersonInjury = (Panel)FormView1.FindControl("PnlPersonInjury");
 Panel pnlPropertyDamage = (Panel)FormView1.FindControl("pnlPropertyDamage");


    RadioButton CTypeP = (RadioButton)FormView1.FindControl("RadioButton1");
    RadioButton CTypeC = (RadioButton)FormView1.FindControl("RadioButton2");
    RadioButton LossLossP = (RadioButton)FormView1.FindControl("RadioButton3");
    RadioButton LossLossI = (RadioButton)FormView1.FindControl("RadioButton4");

    if (LossLossI.Checked)
    {
       // pnlPropertyDamage.Enabled = false;
        PnlPersonInjury.Enabled = true;
        PnlPersonInjury.Visible = true;
        pnlPropertyDamage.Visible = false;
        InjSummmary.Visible = false;
        PropSummary.Visible = false;
    }
    else
    {
        pnlPropertyDamage.Enabled = true;
        PnlPersonInjury.Enabled = false;

        PnlPersonInjury.Visible = false;
        pnlPropertyDamage.Visible = true;
        InjSummmary.Visible = false;
        PropSummary.Visible = false;
    }

    if (CTypeC.Checked)
    {
        cPanel.Enabled = true;
        pPanel.Enabled = false;
        cPanel.Visible = true;
        pPanel.Visible = false;
    }
    else
    {
        cPanel.Enabled = false;
        pPanel.Enabled = true;
        cPanel.Visible = false;
        pPanel.Visible = true;
    }

    UpdatePanel20.Update();
    UpdatePanel2.Update();

I left some of the instantiation of some controls out - so that is not an issue.

+3  A: 

Without seeing the JavaScript, or knowing what part of this code is related to the error, I'd guess that this line is part of your problem:

PnlPersonInjury.Visible = false;

If a server-side control is hidden, it doesn't render anything to the client-side markup.

AaronSieb