我想在删除行之前询问删除按钮是否要求确认。我该怎么做呢?
<dx:GridViewCommandColumn VisibleIndex="3" ButtonType="Image" Width="10px">
<DeleteButton Visible="True" Text="<%$ Resources:GlobalResource, Delete %>" >
<Image Url="../Resources/Imgs/Erase.gif" ToolTip="<%$ Resources:GlobalResource, Delete %>" />
</DeleteButton>
<HeaderCaptionTemplate>
<dx:ASPxButton runat="server" ID="ButtonAddNew" Text="<%$ Resources:GlobalResource, Add %>" ToolTip="<%$ Resources:GlobalResource, Add %>" Image-Url="~/Resources/Imgs/Add.gif" AutoPostBack="False">
<ClientSideEvents Click="function(s, e) { OperationsGrid.AddNewRow(); }" />
</dx:ASPxButton>
</HeaderCaptionTemplate>
</dx:GridViewCommandColumn>
答案 0 :(得分:3)
假设我已经正确理解了你的问题(你想在执行删除之前得到确认消息,对吗?),我已经使用了OnClientClick按钮属性,如下所示:
<asp:ImageButton ID="btnDel" runat="server" ImageUrl="Images/delete-button.jpg" ToolTip="Delete" OnClientClick ="return confirm('Are you sure to delete this record?');"/>
另外,在后面的代码中,为了检查确认框中的哪个按钮被按下(确定/取消),我有以下代码:
if (btnDel.CausesValidation == true) //ok was pressed.
{
//perform delete.
}
稍后编辑:
<dx:ASPxGridView ID="myGrid" runat="server" AutoGenerateColumns="False" ClientInstanceName="GridView1" >
<ClientSideEvents CustomButtonClick="function(s, e) {
e.processOnServer = confirm('Do you really want to apply changes?'); }" />
</dx:ASPxGridView>