[英]Object not set to instance…blah
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! 除了一件事,它工作正常-我的JavaScript不在窗口内! 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. 我忽略了一些控件的实例化-因此这不是问题。
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: 在没有看到JavaScript或不知道该代码的哪一部分与该错误相关的情况下,我猜想这行是您问题的一部分:
PnlPersonInjury.Visible = false;
If a server-side control is hidden, it doesn't render anything to the client-side markup. 如果服务器端控件是隐藏的,则不会向客户端标记呈现任何内容。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.