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)
                @Html.DisplayFor(modelItem => item.partid, new { id = "partCode"})
                @Html.DisplayFor(modelIem => item.partdesc)
                @Html.TextBoxFor(modelItem => item.price, new { id = "priceTextBox", @class = "mytext rightJustified" })


<script src="http://code.jquery.com/jquery-latest.js"></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) { });

Related posts

Recent Viewed