【问题标题】:Problem with "Update panel" control“更新面板”控件的问题
【发布时间】:2011-05-08 06:31:46
【问题描述】:

我正在使用 ASP.NET,其中我使用 Ajaxcontroltoolkit 和“更新面板”控件来更新页面的一部分。
当我第一次运行程序时它工作正常,但从第二次开始“更新面板”控件不起作用。我可以提供更多详细信息,知道是什么问题吗?

<asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>
                <table border="1" id="tbRegistration" style="font-family: Calibri" width="800px">
                    <tr>
                        <td style="width: 33%" align="center">
                            <asp:RadioButton ID="rbIndividual" runat="server" OnCheckedChanged="RadioButton_CheckedChanged"
                                Text="Individual" GroupName="Profile" AutoPostBack="true" />
                        </td>
                        <td style="width: 33%" align="center">
                            <asp:RadioButton ID="rbAgent" runat="server" OnCheckedChanged="RadioButton_CheckedChanged"
                                Text="Agent" GroupName="Profile" AutoPostBack="true" />
                        </td>
                        <td style="width: 33%" align="center">
                            <asp:RadioButton ID="rbBuilder" runat="server" OnCheckedChanged="RadioButton_CheckedChanged"
                                Text="Builder" GroupName="Profile" AutoPostBack="true" />
                        </td>
                    </tr>
                </table>
            </ContentTemplate>
        </asp:UpdatePanel>

【问题讨论】:

  • 是的,我的意思是这样,我添加了代码 sn-p 请检查。我不能接受那些不能解决我的问题的答案。

标签: c# .net asp.net ajax


【解决方案1】:

我认为您必须以这种方式使用更新面板:

<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">

 </asp:UpdatePanel>

【讨论】:

  • 你能解释一下为什么是“有条件的”而不是“总是”吗(我为此阅读了 MSND 文档,但无法弄清楚)
  • 好吧,我还没有使用updatemode,但是使用之后我的问题没有解决。
  • @Menahem 看到这个:stackoverflow.com/questions/5925983/…
【解决方案2】:

如果 UpdateMode 不能解决您的问题,请尝试使用它:

<asp:UpdatePanel ID="UpdatePanel1" UpdateMode="Conditional" ChildrenAsTriggers="false"  runat="server">

</asp:UpdatePanel>

由于 ASP.NET Ajax UpdatePanel 很酷的一点是,当内部引发通常会生成回发的事件时,它的内容会异步更新,人们会认为这是它的默认行为。

但事实并非如此:UpdatePanel 的 UpdateMode 属性有 2 个可能的值:

  • 总是
  • 有条件的

默认值为 Always。

当设置为 Always 时,UpdatePanel 会在每次从页面中的任何位置引发的回发时更新,因此可以从面板内的控件、其他面板内或仅在页面上进行更新。

当设置为 Conditional 时,UpdatePanel 将仅在由面板内的控件或指定的触发器发起的回发时更新。

因此,如果您有多个更新面板,并且不想每次都更新所有更新面板,则必须将 UpdateMode 设置为 Conditional

【讨论】:

    猜你喜欢
    • 2018-12-23
    • 1970-01-01
    • 2013-12-26
    • 1970-01-01
    • 2010-12-22
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多