I want to save any changes made in the textbox field instantaneously to my database, I have the javascript to pass back the changed value to the controller, however I am not aware how pass the unique id with this to save the changed value against.
Below is my view passing the price back to the script, how can I pass the part id with this?
@foreach (var item in Model)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.partid, new { id = "partCode"})
</td>
<td>
@Html.DisplayFor(modelIem => item.partdesc)
</td>
<td>
@Html.TextBoxFor(modelItem => item.price, new { id = "priceTextBox", @class = "mytext rightJustified" })
</td>
</tr>
}
</table>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(function () {
$('#priceTextBox').change(function () {
var changedText = $(this).val();
var partsJava = $("#partCode").val();
//Post the content of your Textbox to your "YourAction" action in "YourController"
$.post('@Url.Action("EnterNewSpecialPrice2", "SpecialPrices")', { "ChangedText": changedText, "PassPartCode": partsJava }, function (data) { });
});
});
</script>