Add Html helpers with Jquery (Razor)
I need to add an @Html.HiddenFor when a button is clicked
My jquery code is this:
function btnAdd() {
var x;
y = $("#drpDwnPRTPP");
$("#budgetsList ul").html('<li>Primer elemento ' +
'@Html.HiddenFor(x => Model.ToList()['+ c +'].PRTPP_ID, new { @id="prtppID"'+ c +', @value="'+ y.val() +'" })' +
'</li>'
);
}
But when i clicked this is what i get in my html :
Primer elemento @Html.HiddenFor(x => Model.ToList()[0].PRTPP_ID, new { @id="prtppID"0, @value="1" })
instead an input element
any way to do this ? ? ...
HTML helpers are server side, Jquery is happening on the client side, so you are going to need to add your hidden field on the client side. See: stackoverflow
链接地址: http://www.djcxy.com/p/83482.html上一篇: 如何自动添加文本框