Instead of using replaceWith
may I suggest the use of another function, the function .attr()
that is meant to replaced the attributes of an element.
$('td').attr('id','@Html.ValueFor(x => x.name)');
Also, be careful because the ASP values will not be available once in the client side. Your selector $('td')
is pretty general, and IDS must be unique.