0


我已将 GridView 放置在 Updatepanel 中,并在那里定义了几个带有一个 LinkBut​​ton 的列。但是对于那个 LinkBut ​​ton OnClientClick事件没有触发。相反,它正在回发。
以下是代码:

<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为 lnkRemove 的LinkBut​​ton应该在用户点击它时显示一个确认消息框。但它没有显示出来。
我已经尝试从后面的代码中注册异步 PostBack 事件,如下所示:

ScriptManager.GetCurrent(this).RegisterAsyncPostBackControl(lbRemove);

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

4

2 回答 2

0

使用PostBackTrigger

<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>
于 2015-05-18T11:41:05.990 回答
0

请在链接按钮上使用它OnClientClick

 OnClientClick='return confirm("Are you sure you want to Delete this?");return false;'
于 2015-05-22T05:29:50.267 回答