Is it possible to fire datalist_ItemCommand
function in page load after post back. It doesn't make sense but I need to achieve this.
Here is the scenerio: I have datalist
control and it loaded with some person data. It has got a delete button in itemTemplate
.
<ItemTemplate>
<tr>
<td><%# Eval("Name") %></td>
<td><%# Eval("EMail") %></td>
<td align="center"><asp:LinkButton ID="btnDelete" runat="server" CommandName="delete" CommandArgument='<%#Eval("id") %>' OnClientClick="confirmMe('My Program title','Are you sure ?','Yes', 'No', 'datalist1_ItemCommand'); return false;"></asp:LinkButton></td>
</tr>
</ItemTemplate>
When delete button clicked, custom modal box showing and wait for user response. If user click yes in modal box then itemCommand function should be fired. That's why you see datalist_ItemCommand
function in OnClientClick
attribute.
Here is JS :
function confirmMe(title, content, button_ok, button_no, asp_control) {
swal({
title: title,
text: content,
type: "warning",
showCancelButton: true,
confirmButtonColor: "#8dc63f",
confirmButtonText: button_ok,
cancelButtonText: button_no,
closeOnConfirm: false,
closeOnCancel: true
},
function (result) {
if (result === true)
__doPostBack(asp_control, '');
});
}