对象未设置为实例....blah

发布于 2024-08-08 06:42:26 字数 1597 浏览 2 评论 0原文

我有自动回发并将面板设置为可见或不可见的单选按钮。整个页面位于更新面板中,以便我可以强制它更新并显示不可见的更改。单选按钮也位于更新面板中。

它工作得很好,除了一件事——我的 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();

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

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

再见回来 2024-08-15 06:42:26

如果没有看到 JavaScript,或者不知道该代码的哪一部分与错误相关,我猜这一行是您问题的一部分:

PnlPersonInjury.Visible = false;

如果服务器端控件被隐藏,它不会向客户端呈现任何内容 -侧面标记。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文