UpdatePanel 中 ListView 中的 LinkButton 导致完全回发
我在 UpdatePanel 的 ListView 中有一个 LinkButton.我希望按钮(好吧,其中任何一个)导致部分回发,但它们导致整页回发.
I have a LinkButton in a ListView in an UpdatePanel. I would like the button (well, any of them) to cause a partial postback, but they are causing a full page postback.
<asp:UpdatePanel ID="upOutcomes" UpdateMode="Conditional" runat="server">
<ContentTemplate>
<asp:ListView ID="lvTargets" runat="server" onitemdatabound="lvTargets_ItemDataBound">
<ItemTemplate>
<asp:LinkButton ID="lnkAddTarget" CssClass="lo" Text='<%# Eval("Title") + " <b>" + Eval("Level") + Eval("SubLevel") + "</b>" %>' runat="server"></asp:LinkButton>
</ItemTemplate>
</asp:ListView>
</ContentTemplate>
</asp:UpdatePanel>
我在 stackoverflow 上发现了另一篇文章,建议添加这个:
I found another post on stackoverflow which suggested adding this:
protected void lvTargets_ItemDataBound(object sender, ListViewItemEventArgs e) {
var lb = e.Item.FindControl("lnkAddTarget") as LinkButton;
tsm.RegisterAsyncPostBackControl(lb); // ToolkitScriptManager
}
没有任何区别...
还有一些其他类似的帖子,但我找不到解决方案!有什么想法吗?
There are a few other similar posts too, but I can't find a solution! Any ideas?
ASP.NET 4 中的 ClientIDMode 设置允许您指定 ASP.NET 如何为 HTML 元素生成 id 属性.
The ClientIDMode setting in ASP.NET 4 lets you specify how ASP.NET generates the id attribute for HTML elements.
在以前的 ASP.NET 版本(即 pre 4)中,默认行为等效于 ClientIDMode 的 AutoID 设置.但是,默认设置现在是可预测.
In previous versions of ASP.NET (i.e. pre 4), the default behavior was equivalent to the AutoID setting of ClientIDMode. However, the default setting is now Predictable.
为此需要使用 AutoId,因为脚本管理器希望在以前版本的 .NET 中生成 HTML 控件.
AutoId is required for this because of the way the script manager expects the HTML controls to be generated in previous versions of .NET.