I am using html.checkbox
in my mvc appplication , it will generate the html like
<input checked="checked" id="cb17" name="reports" type="checkbox" value="sdf" />
<input name="reports" type="hidden" value="false" />
<input checked="checked" id="cb18" name="reports" type="checkbox" value="ty" />
<input name="reports" type="hidden" value="false" />
when the form gets posted it is sending all the values of html.checkbox to mvc action through model binding concept.
reports[0]-"sdf"
reports[1]-"false"
reports[2]="ty"
reports[3]="false"
i knew html.checkbox will create the hidden fields internally, but when i posting the form it need to send either one value of checkbox. why it is sending hidden fields too. how to avoid this.
referred the below link
asp.net mvc: why is Html.CheckBox generating an additional hidden input
but not able to get the proper understanding.
Aucun commentaire:
Enregistrer un commentaire