【发布时间】:2011-04-15 13:48:41
【问题描述】:
我正在尝试加快我的转发器,以便在每次调用时不必通过 AJAX UpdatePanel 重新发送尽可能多的 HTML。
这就是我所拥有的(一个非常简化的版本):
<asp:Repeater ID="rptContactSteps" runat="server">
<ItemTemplate>
<p>Script:<br /><%#mobjSDIT.FormatText(Eval("script"))%></p>
<p>Notes:<br /><%#mobjSDIT.FormatText(Eval("notes"))%></p>
<asp:UpdatePanel ID="upStep" runat="server" UpdateMode="Conditional">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="rptContactSteps" EventName="ItemCommand" />
</Triggers>
<ContentTemplate>
<p>Contact/Step Notes:<br /><%#mobjSDIT.FormatText(Eval("contact_step_notes"))%></p>
<asp:ImageButton ID="btnSaveAndCompleteLastStep" runat="server" ImageUrl="~/images/content/buttons/save-and-complete-button.png" CommandArgument='<%#Eval("step_contact_tie_id")%>' />
</ContentTemplate>
</asp:UpdatePanel>
</ItemTemplate>
</asp:Repeater>
所以,当我单击“btnSaveAndCompleteLastStep”时,我希望“rptContactSteps”中的所有 UpdatePanel 都能更新。在 ItemTemplate 中包含 UpdatePanel 应该有助于避免重新加载填充 Eval("script") 和 Eval("notes") 的 html/文本,因为这些变量的值可能非常大并且超过 3G 连接这可能会非常昂贵(时间和金钱)。
我虽然通过添加异步触发器它可以工作,因为我以前使用过这种类型的触发器,但不是在中继器内时。目前,UpdatePanel 根本没有更新,除了按下按钮的那个。
有什么想法吗?
【问题讨论】:
-
为什么不尝试制作 ImageButton 的默认单击事件,复制粘贴 ItemCommand 代码并更改 AsyncPostBackTrigger 中 ImageButton“单击”的事件名称。这对我有用。
-
更新面板和 Ajax 不属于同一个句子。我建议你看看这篇文章:encosia.com/2007/07/11/… 作者解释说,他看到使用 Ajax 而不是更新面板有 4,000% 的改进。
-
Nick,我很欣赏“编写”我自己的 AJAX 会更快,因为我经常这样做,但对于快速开发,我发现 UpdatePanels 非常方便。
标签: asp.net ajax vb.net updatepanel repeater