【问题标题】:Asyncpostback using standard button使用标准按钮的异步回发
【发布时间】:2011-08-15 09:36:08
【问题描述】:

使用更新面板,我尝试使用标准 html 按钮执行异步回发。

我试过这个:

<asp:UpdatePanel runat="server" ID="MyUpdatePanel">
    <Triggers>
        <asp:AsyncPostBackTrigger ControlID="btnMyButton" EventName="Click" />
    </Triggers>
    <ContentTemplate>
       <button runat="server" id="btnMyButton">ASyncPostBack</button>
    </ContentTemplate>
</asp:UpdatePanel>

<asp:UpdatePanel runat="server" ID="MyUpdatePanel">
    <Triggers>
    </Triggers>
    <ContentTemplate>
       <button runat="server" id="btnMyButton">ASyncPostBack</button>
    </ContentTemplate>
</asp:UpdatePanel>


AsyncPostBackTrigger trigger = new AsyncPostBackTrigger();
trigger.ControlID = MyControl.ID;
trigger.EventName = "Click";
MyUpdatePanel.Triggers.Add(trigger);

根据我的脚本管理器IsInAsyncPostBack 判断,这些解决方案似乎都行不通。

我没有使用标准的 ASP.NET 按钮,因为 jQuery 存在问题,我知道我可以在页面内放置一个隐藏的 ASP.NET 按钮并触发它,但我希望有更好的解决方案。

【问题讨论】:

  • 请详细说明这些要点。您使用的是哪个 asp.net 版本,asp:Button 与 jQuery 有什么具体问题?
  • 当 ASP.NET 按钮没有指定 text 属性时,jQuery 将无法正确呈现它们。

标签: c# jquery asp.net ajax updatepanel


【解决方案1】:

事件名称应为EventName="onserverclick" 而不是EventName="Click"

【讨论】:

    【解决方案2】:

    只是为了更新其他人,它现在可以作为EventName="serverclick"

    【讨论】:

      猜你喜欢
      • 2012-02-11
      • 1970-01-01
      • 2011-04-19
      • 1970-01-01
      • 2020-04-12
      • 2012-02-27
      • 2023-02-26
      • 2011-03-09
      • 1970-01-01
      相关资源
      最近更新 更多