我已经将我的GridView放在了更新文件中,在那里,我用一个LinkButton定义了几个列。但对此,LinkButton 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为LinkButton的lnkRemove应该在用户单击它时显示一个确认消息框。但它并没有显示出来。
我尝试将异步PostBack事件从后面的代码注册到这里,如下所示:
ScriptManager.GetCurrent(this).RegisterAsyncPostBackControl(lbRemove);
请任何人帮我解决这个问题。
发布于 2015-05-18 11:41:05
使用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-22 05:29:50
请在链接按钮的OnClientClick
上使用这个
OnClientClick='return confirm("Are you sure you want to Delete this?");return false;'
https://stackoverflow.com/questions/30301650
复制相似问题