javascript - Setting a hidden field and accessing it in MVC4 -



javascript - Setting a hidden field and accessing it in MVC4 -

i have need create hidden field in of table. later upon button click, need retrieve info saved in hidden field. below code:

class="snippet-code-html lang-html prettyprint-override"><td> <input id="hdnr<%=rownumber%>c<%=columnnumber%>" type="hidden" value="{{html.hiddenfor(model => item.key)}}" /> </td>

where rownumber , colnumber variables. later in jquery, upon button click, attempting retrieve value of hidden field per code below:

class="snippet-code-js lang-js prettyprint-override">var value = $('#hdnr'+i+'c'+j).val(); alert(value);

somewhere wrong. either value not getting saved in html tag or not beingness retrieved correctly. please help. in advance.

your value in input not correct. can set value straight model.

<input id="hdnr<%=rownumber%>c<%=columnnumber%>" type="hidden" value="<% model.key %>" />

if want utilize helper, in case id generated automatically. :

html.hiddenfor(model => item.key)

you can still add together custom attribute. i'm not sure of syntax :

html.hiddenfor(model => item.key, { @class = "myclass" })

javascript jquery html asp.net-mvc-4 hiddenfield

Comments

Popular posts from this blog

java Multi query from Mysql using netbeans -

c# - DotNetZip fails with "stream does not support seek operations" -

c++ - StartServiceCtrlDispatcher don't can access 1063 error -