网格行命令不等待javascript的警报响应 [英] Grid row command is not waiting for javascript's alert response
问题描述
大家好,
在我的网格视图行命令中,我想删除带有确认警告框(javascript alert)的行,upto警告框工作正常,但问题是,The Row命令会立即触发,而不是等待警报框
网格控制
------------
Hi all,
In my grid view row command i want to delete the row with confirmation alert box(javascript alert ), upto alert box is working fine , but the problem is , The Row command is fired immediately that is not waiting for alert box
grid control
------------
<asp:TemplateField ItemStyle-Width="25px" ItemStyle-Height="15px">
<ItemTemplate>
<asp:ImageButton ID="lnkswi_del" runat="server" CommandName="Delete" ToolTip="Delete"
CommandArgument="<%#CType(Container,GridViewRow).RowIndex%>" ImageUrl="~/Images/delete.png" CssClass="test" OnClientClick="return Confirmdelete();" />
</ItemTemplate>
</asp:TemplateField>
javascript
--- --------
javascript
-----------
function ConfirmDelete() {
alertify.set({ buttonReverse: true });
alertify.confirm('Are you sure you want to delete the record?', function (e) {
if (e) {
return true;
} else {
return false;
}
});
}
代码背后
-----------
code behind
-----------
Protected Sub gridTran_RowCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles gridTran.RowCommand
If e.CommandName = "Delete" Then
Dim index As Integer = Convert.ToInt32(e.CommandArgument)
Dim gvRow As GridViewRow = gridTran.Rows(index)
trxnno = gvRow.Cells(1).Text
deletemethod() // this method will delete the row
End If
单击警报框后确定只有行命令事件应该触发,但它不是
帮我解决这个问题
而且,我通过rowdatabound事件做到了,同样的问题也出现了
after click the alert box ok only the row command event should fire , but its not
help me resolve this
and also , i did it through rowdatabound event, ther also the same problem is occuring
Protected Sub gridTran_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles gridTran.RowDataBound
If (e.Row.RowType = DataControlRowType.DataRow) Then
Dim theDeleteButton As ImageButton = CType(e.Row.Cells(0).FindControl("lnkswi_del"), ImageButton)
theDeleteButton.OnClientClick = "return ConfirmDelete();"
End If
End Sub
提前感谢
Velsamy
thanks in advance
Velsamy
推荐答案
只需浏览链接
http://www.aspsnippets.com/Articles/Server-Side-Code-Behind-Yes-No-Confirmation-Message-Box-in-ASPNet.aspx [ ^ ]
它将帮助您完成任务。
Just go through the link
http://www.aspsnippets.com/Articles/Server-Side-Code-Behind-Yes-No-Confirmation-Message-Box-in-ASPNet.aspx[^]
It will help you achieve your task.
这篇关于网格行命令不等待javascript的警报响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!