2009-10-21 141 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; 

如果服務器端控件隱藏它不會向客戶端標記提供任何內容。

相關問題