Controller:
[HttpPost]
public void DeleteState(string id)
{
int id1=Convert.ToInt32(id);
var _db = new clubDataContext();
var state = from m in _db.StateInfos where m.S_ID == id1 select m;
foreach (var m in state)
{
_db.StateInfos.DeleteOnSubmit(m);
}
try
{
_db.SubmitChanges();
}
catch (Exception e)
{
Console.WriteLine(e);
}
}
View:
<input id="state-id" type="text" value=@item.S_ID style="display:none"/>
<td>
<a id="delete-link" href="" >Delete</a>
</td>
$("#delete-link").click(function(){
$.ajax({
url: '@Url.Action("DeleteState", "ManageSystem")',
data: {'id':$("#state-id").val(); } ,
success: function(result) {
$('#edit-state').html("State Deleted Successfully");
}
});
}
});
I don't know what is the reason but controller method is not called when i click on Delete. Is there Ajax problem? I have included Ajax Library.
Main thing I forgot to mention that My view is partial view and I am calling controller method from this partial view. So I think jQuery is not loaded