I have one problem in my Asp.net Mvc 3 project. I am using data first approach and strong type view. I hide one value on view from model as,
@Html.TextBoxFor(model => model.myfield1, new { style=" display:none" })
when I access this field value on java script I get null value or blank.
var abc= s("#myfield1").val();
alert(abc)
I will try like
@Html.DisplayFor(model => model.myfield1, new{})
value will display on view. I also try using hidden field but not work
have any issue or solution for this. I not display this field on view but this value required for further purpose.
$("#myfield1").val();(nots). And if its returningnull, then its because yourmyfield1property isnull- check the html your generating - it will be showingvalue="". But ifDisplayFor()is showing a value, then its aModelStateissue and you need to shown the code in your controller methods associated with this view