Hi, I'm having a hard time finding a simple enough (ELI5) direct answer to on here and the interwebz
If I have the following html fragment on a razor page. How does the clicked button bind to the viewmodel Gender property (transfer data to/from viewmodel property and radiobutton input element)? If I understand it correctly, this binding happens server-side after a POST. This fragment below would have been inside a form, so ALL (male, female in this case) the radio button input types will get sent together with the hidden element. The expression parameters is what tells server-side to associate the radio buttons to the viewmodel property. Also, doesn't the expression already tell what to bind the radiobutton to (ie the hiddenfor is not necessary)?
If I have the following html fragment on a razor page. How does the clicked button bind to the viewmodel Gender property (transfer data to/from viewmodel property and radiobutton input element)? If I understand it correctly, this binding happens server-side after a POST. This fragment below would have been inside a form, so ALL (male, female in this case) the radio button input types will get sent together with the hidden element. The expression parameters is what tells server-side to associate the radio buttons to the viewmodel property. Also, doesn't the expression already tell what to bind the radiobutton to (ie the hiddenfor is not necessary)?
<pre lang="Razor"> @model Student<div> @Html.RadioButtonFor(m => m.Gender,"Male") @Html.RadioButtonFor(m => m.Gender,"Female") @Html.HiddenFor(model => model.Gender)</div>