LinkBut​​ton的ListView中的UpdatePanel中导致完全回发 [英] LinkButton in ListView in UpdatePanel causes full postback

查看:145
本文介绍了LinkBut​​ton的ListView中的UpdatePanel中导致完全回发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个LinkBut​​ton在一个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.

阅读Microsoft文章

自动识别是必需的,因为脚本经理预计将在.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.

这篇关于LinkBut​​ton的ListView中的UpdatePanel中导致完全回发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆