I am calling jQuery dialog from @Html.ActionLink
But I am confused to pass action parameters to jQuery dialog. How to pass them CommunicationLocation
and CommunicationType
to jQuery dialog?
@Html.ActionLink("Delete", "DeleteEmail", null, new { CommunicationLocation
= commemail.CommunicationLocation, CommunicationType = "email" },
new { @class = "modalDialog btn btn-success" })
Dialog Div
<div id="dialog-confirm" title="Delete the item?">
<p><span class="ui-icon ui-icon-alert" style="float:left; margin:0 7px 20px 0;"></span>This item will be deleted. Are you sure?</p>
</div>
JS
<script type="text/javascript">
$(document).ready(function () {
$("#dialog-confirm").dialog({
autoOpen: false,
modal: true,
resizable: false,
height: 180,
});
$('.modalDialog').click(function () {
$("#dialog-confirm").dialog({
buttons: {
"Confirm": function () {
$.ajax({
url: 'customer/DeleteEmail',
type: 'Post',
data: //Need to pass parameters here,
success: function (result) {
$('#DivEmailContainer').html(result);
}
});
$(this).dialog('close');
},
"Cancel": function () {
$(this).dialog("close");
}
}
});
$("#dialog-confirm").dialog("open");
return false;
});
</script>
Controller
[HttpPost]
public PartialViewResult DeleteEmail(string CommunicationLocation, string CommunicationType)
{
//Code here
}