I have an UltraWebGrid with data in it, a WebNavBar displaying the add and delete buttons, and they are tied togeather by the GridID.
I want to add a client side confirmation message before the delete event executes. The add and delete events work fine. Whatever I seem to do, the page still posts back and the row delete event fires, even when the user declines the confirmation.
The actual deletion is handled by a server side delete row event:
this.uwgWorkflowDetails.DeleteRow +=new DeleteRowEventHandler(uwgWorkflowDetails_DeleteRow); private void uwgWorkflowDetails_DeleteRow(object sender, RowEventArgs e){ decimal strId = Convert.ToDecimal(e.Row.Cells.FromKey(SfaWorkflowDTLDisplaySetDCFields.PrimaryKeyFieldName).Value); [call to database deletion method] }
this.uwgWorkflowDetails.DeleteRow +=new DeleteRowEventHandler(uwgWorkflowDetails_DeleteRow);
private void uwgWorkflowDetails_DeleteRow(object sender, RowEventArgs e){ decimal strId = Convert.ToDecimal(e.Row.Cells.FromKey(SfaWorkflowDTLDisplaySetDCFields.PrimaryKeyFieldName).Value);
[call to database deletion method]
}
I have set up a clent side event:
wnbWorkflowDetails.ClientSideEvents.BeforeDeleteRow = "BeforeRowDeleted"; (where wbnWorkflowDetails is the web nav bar)
And registered the script block in the page:
function BeforeRowDeleted(oNavBar, oButton, oEvent) {if(confirm('ÀÀréé yóóüü sure you wíísh to delete?')){oEvent.needPostBack = true;return false;}else{oEvent.needPostBack = false;return true;}}
The client side event fires, and the confirmation box is displayed, but with either response the row is deleted.
You need to modify BeforeRowDeleted that way:function BeforeRowDeleted(oNavBar, oButton, oEvent) { oEvent.cancel = !confirm('delete?');}
Best,Nick