I use a webmethod to identify whether the user can "Delete a record".
Here is the JavaScript code before adding this access control.
$(".apply-delete-msg").live('click', function() {
return confirm("Are you sure you want to delete this item(s)?);
});
Now it will call the webMethod to validate the access
<WebMethod(EnableSession:=True)> _
Public Function CanAccess() As Boolean
Return ServerCode.IsAccessable
End Function
The new JavaScript then:
$(".delete-msg").live('click', function() {
MPWebService.CanAccess(
//B
function(boolRes) {
if (boolRes == true){
return confirm("Are you sure you want to delete this item(s)?");}
else{
alter("can't access");
return false;
}
});
// **Here is Comment A**: Return true/false
});
I want the ".Live" method to return a true/false if the user can access and confirm delete/cannot access or cancel the delete.
But if i'm right the method will call CanAccess first, and then Comment A:, finally Comment B, i.e. function(boolRes).
Because the value of boolRes is inside function(boolRes) and it is processed at last, it's tricky for me to get a return value from this method at Comment A position.
Any suggestions?