首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >为什么LinkButton内部的GridView存在于Updatepanel不触发OnClientClick事件?

为什么LinkButton内部的GridView存在于Updatepanel不触发OnClientClick事件?
EN

Stack Overflow用户
提问于 2015-05-18 11:10:39
回答 2查看 1K关注 0票数 0

我已经将我的GridView放在了更新文件中,在那里,我用一个LinkButton定义了几个列。但对此,LinkButton OnClientClick事件并不会触发。相反,它在做回发。

以下是守则:

代码语言:javascript
运行
复制
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
   <ContentTemplate>
      <asp:GridView ID="gvUnmappedICD" runat="server" EmptyDataText="No Records are added yet."
             OnRowCommand="gvUnmappedICD_RowCommand" OnRowDataBound="gvUnmappedICD_RowDataBound">
          <Columns>
             <asp:TemplateField HeaderText="Action">
                 <ItemTemplate>
                    <asp:LinkButton ID="lnkRemove" runat="server" CommandArgument='<%#Eval("KEYWORD") %>' CommandName="remove" ClientIDMode="AutoID"
                        OnDataBinding="lnkRemove_DataBinding" OnClientClick='return confirm("Are you sure you want to Delete this?");' ToolTip="Click to Remove this record." Text="Remove" />
                 </ItemTemplate>
          </Columns>
      </asp:GridView>
   </ContentTemplate>
</asp:UpdatePanel>

这个ID为LinkButton的lnkRemove应该在用户单击它时显示一个确认消息框。但它并没有显示出来。

我尝试将异步PostBack事件从后面的代码注册到这里,如下所示:

代码语言:javascript
运行
复制
ScriptManager.GetCurrent(this).RegisterAsyncPostBackControl(lbRemove);

请任何人帮我解决这个问题。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2015-05-18 11:41:05

使用PostBackTrigger

代码语言:javascript
运行
复制
<asp:ScriptManager ID="scriptManager" runat="server">
        <asp:UpdatePanel ID="updatePanel" runat="server">
            <asp:GridView ID="gvUnmappedICD" runat="server" EmptyDataText="No Records are added yet."
         OnRowCommand="gvUnmappedICD_RowCommand" OnRowDataBound="gvUnmappedICD_RowDataBound">
      <Columns>
         <asp:TemplateField HeaderText="Action">
             <ItemTemplate>
                <asp:LinkButton ID="lnkRemove" runat="server" CommandArgument='<%#Eval("KEYWORD") %>' CommandName="remove" ClientIDMode="AutoID"
                    OnDataBinding="lnkRemove_DataBinding" OnClientClick='return confirm("Are you sure you want to Delete this?");' ToolTip="Click to Remove this record." Text="Remove" />
             </ItemTemplate>
      </Columns>
  </asp:GridView>
            <Triggers>
                <asp:PostBackTrigger ControlID="lnkRemove" />
            </Triggers>
       </asp:UpdatePanel>
票数 0
EN

Stack Overflow用户

发布于 2015-05-22 05:29:50

请在链接按钮的OnClientClick上使用这个

代码语言:javascript
运行
复制
 OnClientClick='return confirm("Are you sure you want to Delete this?");return false;'
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/30301650

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档