I am currently trying to call a method from my view to change a boolean in my database, the only thing i don’t know since i am not really familiar with MVC is that whenever i call my controller method it gives me a blank page. I just want to call the method but stay in the actual view.
Here is the part of code in my view.
<td><a href="@Url.Action("PutInBin", "Capture", new { captureId = @Model.Files.Captures.ElementAt(i).Capture_Id })", onclick="DeleteCapture(@(i + 1))">Delete</a></td>
And here is the method in my controller
public void PutInBin(int captureId)
{
QueryCaptureToBin queryCaptureToBin = new QueryCaptureToBin();
queryCaptureToBin.Capture_Id = captureId;
client.PlaceCaptureInBin(queryCaptureToBin, userParams);
}
You could use AJAX:
and don’t forget to include the
jquery.unobtrusive-ajax.jsscript to your page:and your controller action:
and if you wanted to get notification when the delete finishes:
and then you would have your
onDeleteSuccessjavascript function: