LinkButton的ListView中的UpdatePanel中导致完全回发
我有一个LinkButton在一个UpdatePanel一个ListView。我想按钮(当然,其中的任何)造成局部回传,但他们所造成的一整页回发。
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>
我发现计算器另一个帖子里面建议增加这样的:
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
}
这还没有做出区别...
It hasn't made a difference...
有一些其他类似的帖子太多,但我不能找到一个解决办法!任何想法?
There are a few other similar posts too, but I can't find a solution! Any ideas?
,可以指定ASP.NET生成的HTML元素的id属性在ASP.NET 4中的ClientIDMode设置。
The ClientIDMode setting in ASP.NET 4 lets you specify how ASP.NET generates the id attribute for HTML elements.
在previous ASP.NET版本(即pre 4),默认的行为相当于的ClientIDMode的自动识别设置。但是,默认设置是现在的 predictable 的。
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.
自动识别是必需的,因为脚本经理预计将在.NET的previous版本生成的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.