2009-10-21 116 views
0

我有单选按钮,autopostback并将面板设置为可见或不可见。整个页面位于更新面板中,以便我可以强制更新并显示不可见的更改。单选按钮也在更新面板中。对象未设置为实例....等等

它工作正常,除了一件事 - 我的JavaScript走出了窗口!面板更新后,它找不到我的任何控件。

有没有办法解决这个问题?

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(); 

我留下了一些控件的实例化 - 所以这不是问题。

回答

3

在没有看到JavaScript或知道这是什么代码的一部分是有关错误,我猜想,这条线是你的问题的一部分:

PnlPersonInjury.Visible = false; 

如果服务器端控件隐藏它不会向客户端标记提供任何内容。

相关问题