【问题标题】:How can I update only specific portion of a page?如何仅更新页面的特定部分?
【发布时间】:2011-07-18 16:41:48
【问题描述】:

我在我的 aspx 页面中使用了两个更新面板。我的页面还包含其他控件,其中大部分是文本框。一些使用 ajaxwater 标记扩展器的文本框。我的问题是当面板的部分更新时,水印文本框也更新了。我怎样才能防止这种情况发生? 我的页面就像 ....一些其他控件,然后

<asp:UpdatePanel runat="server" ID="upPanelTestRoll">
                        <ContentTemplate>
                            <fieldset style="height: 70px; float: left; width: 350px;">
                                <legend>Submission</legend>
                                <asp:CheckBox ID="chkSubmitted" runat="server" Height="25px" Width="25px" AutoPostBack="true" />
                                <label for="chkSubmitted">
                                    Submitted</label>
                                <label for="txtSubmissionDate">
                                    Submission Date</label>
                                <asp:TextBox ID="txtSubmissionDate" runat="server" Height="12px" Enabled="false"></asp:TextBox>
                                <cc1:CalendarExtender ID="txtSubmissionDate_CalendarExtender" runat="server" Enabled="True"
                                    TargetControlID="txtSubmissionDate">
                                </cc1:CalendarExtender>
                                <%--<asp:CheckBox ID="chkTestToAppear" runat="server" Height="25px" Width="25px" />
                            <label for="">
                                Test To Appear</label>--%>
                                <br />
                                <label for="txtAdmissionTestRoll">
                                    Admission Test Roll
                                </label>
                                <asp:TextBox ID="txtAdmissionTestRoll" runat="server" Enabled="false"></asp:TextBox>
                        </ContentTemplate>
                    </asp:UpdatePanel>

如何优化代码?

【问题讨论】:

  • 我不明白这个问题。如果您只想更新页面的某些部分,则必须在相应的 UpdatePanel 上调用 Update(如果设置为 Conditional)。如果你不想更新的控件在这个UpdatePanel里面,你必须把它分成两个UpdatePanel,这样只会更新正确的那个。

标签: .net asp.net ajax updatepanel


【解决方案1】:

UpdatePanel.UpdateMode 更改为有条件的。

UpdatePanel控件的内容更新如下 条件:如果调用UpdatePanel控件的Update方法 明确的。

如果使用 Triggers 属性将控件定义为触发器 UpdatePanel 控件并导致回发。在这种情况下, control 是用于更新面板内容的显式触发器。这 触发控件可以在 UpdatePanel 内部或外部 定义触发器的控件。

如果 ChildrenAsTriggers 属性设置为 true 并且子控件 的 UpdatePanel 控件会导致回发。在这种情况下,孩子 UpdatePanel 控件的控件是用于更新的隐式触发器 面板。嵌套 UpdatePanel 控件的子控件不会导致 要更新的外部 UpdatePanel 控件,除非它们是明确的 定义为触发器。

【讨论】:

    猜你喜欢
    • 2016-06-15
    • 1970-01-01
    • 2011-08-08
    • 2011-03-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-12-17
    相关资源
    最近更新 更多