I have a View that includes:
(...)
<div id="txtMan@(item.ManufacturerId)" hidden>
@Html.TextBoxFor(modelItem => item.ManufacturerName, new { @id = "txtBoxMan"+item.ManufacturerId })
</div>
<td>
<input class="btnSave" id="btnSave@(item.ManufacturerId)" type="button" value="Save" onclick="saveButtonPressed(@item.ManufacturerId);" hidden />
</td>
(...)
The accompanying JavaScript function:
saveButtonPressed = function (id) {
var newManName = $('#txtMan' + id).val();
$.ajax({
type: "POST",
async: true,
url: '/Admin/BrandConfigurationNameUpdate/' + newManName,
dataType: "json",
success: function () {
alert('Added');
}
});
}
And the Controller method:
public static void BrandConfigurationNameUpdate(string id)
{
}
My goal is to store the text box input in the database. However, when I put a breakpoint in my Controller, it never gets hit. Any suggestions?
UPDATE: I attempted using GetJSON, but it still doesn't work. Here's the code snippet:
saveButtonPressed = function (id) {
var newManName = $('#txtBoxMan' + id).val();
alert(newManName);
var URL = "~/Areas/Admin/Controller/Admin/BrandConfigurationNameUpdate/";
$.getJSON(URL, { "id": id, "newManName": newManName }, function (data) {
alert("finished");
});
}