I need to pass the Id of a object into a html element (razor part), but it doesn't recognize it. Look like the Id is not in its scope, or something. Is there a way to pass the value into the razor part of my html element in the append function?

$.ajax({
        data: data,
        url: url + "?searchTerm=" + data

    }).success(function (response) {

        console.log(response);
        var table = $('#companyTable');
        var tBody = table.children('tbody');
        tBody.html("");
        var textbox = document.getElementById("searchBar");
        textbox.value = "";

        tBody.append(
            "<tr><td>" +response.CompanyName + " </td><td>" +
                       response.CompanyIdNumber + "</td><td>" +
                       response.CompanyTaxNumber + "</td><td>" +
           "<p><button onclick=\"location.href='@Url.Action("Edit", "Company", new { @id = response.CompanyId  })'\"> Edit</button></p>" +
                           "</td></tr>"
                );
            table.removeClass("hidden");
            var originalTable = $('#originalTable');
            originalTable.remove();

        }).error(function (response) {
            console.log(response);
        });
    }

Thank you.

Related posts

Recent Viewed