Problem Statement: Not able to trigger the Java-script Function from Ajax Action Link,but i'm able to trigger the same Java-script function using html.actionlink
What i'm doing: Actually i'm having grid of details and link for delete on each row,on-click of delete i want to pass value to an action result called Delete by using Javascript/Jquery function.
What i'm trying to avoid: On click of delete it should not navigate to new url as it happens with html.actionlink,so i'm using ajax.actionlink for this:
Please find the image for your reference:

View:
<table class="table">
<tr>
<th>
@Html.DisplayNameFor(model=> model.RequestedBy)
</th>
<th>
@Html.DisplayNameFor(model=> model.Description)
</th>
<th>
@Html.DisplayNameFor(model=> model.Name)
</th>
<th>
@Html.DisplayNameFor(model=> model.FromDate)
</th>
<th>
@Html.DisplayNameFor(model => model.ToDate)
</th>
</tr>
@if (Model!= null)
{
foreach (var item in Model)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.RequestedBy,new { id="lstRequestedBy"})
@Html.Hidden("#RequestedBy")
</td>
<td>
@Html.DisplayFor(modelItem => item.Description)
</td>
<td>
@Html.DisplayFor(modelItem => item.FromDate)
</td>
<td>
@Html.DisplayFor(modelItem => item.ToDate)
</td>
<td>
@Ajax.ActionLink("Delete","Delete","Request",
new AjaxOptions
{
OnBegin="return DeleteAsset()",
HttpMethod = "POST"
})
@*@Html.ActionLink("Delete","Delete","Request", new { onclick="DeleteAsset()"})*@
</td>
</tr>
}
}
</table>
Javascript:
<script type='text/javascript'>
function DeleteAsset() {
var RequestedBy= $('#lstRequestedBy').val();
$('#RequestedBy').val(RequestedBy);
}
</script>
Controller:
public ActionResult Delete(string RequestedBy)
{
//Want to perform some action here based on RequestedBy
}
What i'm doing wrong here??
Why java-script function is not getting triggered with ajax.actionlink,which is getting triggered using html.actionlink??
It is also fine if any one provides alternative for this????