Monday, 15 April 2013

asp.net mvc - Set a hardcoded value in a HiddenFor within a for-loop -


When there is only one person to select, then people should specify people [hardcod] value 'TRUE' I need to do

  @if (hasMoreThanOnePerson) {& lt; Td> I have selected assets to satisfy my verification. @html CheckboxFor (M => M.Peepal [I]. Season Selected) & lt; / Td> } Else {@ Html.HiddenFor (m = & gt; m.People [i] is selected, true) / / always set TRUE in hidden field for loop with indicator}  

to hide value to use text> itemprop = "text">

html properties Using the property of the field or:

  @ html.HiddenFor (m => m.People [i]. Is selected, new {value = "true"})  

This will output to HTML:

  & lt; Input id = "YourModel.People [0] .Is selected" name = "YourModel.People [0] .Is selected" type = "hidden" value = "true" & gt;  

No comments:

Post a Comment