c# - binding with Model field? -



c# - binding <input type="radio"> with Model field? -

in view have 2 <input type="radio">, combine create radio group.

i want bind them field of model, in way if value true should bind first radio button if false should bind other.

please guide how can achived. tried below code checked sec radio no matter value model has.

<div class="radiobuttons"> <input type="radio" name="lendertype" checked="@model.filter_value" id="rbtnalllenders" class="cb"> <input type="radio" id="rbtnmajorlendersonly" checked="!@model.filter_value" name="lendertype" class="cb"> </div>

the input typed radio needs have value set. if radio checked, value sent name in model.

view model

public class someviewmodel { public int myradiovalue { get; set; } }

input element

<input type="radio" value=1 name="myradiovalue" /> <input type="radio" value=2 name="myradiovalue" /> <input type="radio" value=3 name="myradiovalue" />

c# .net asp.net-mvc asp.net-mvc-4 razor-2

Comments

Popular posts from this blog

php - How to pass multiple values from url -

xslt - DocBook 5 to PDF transform failing with error: "fo:flow" is missing child elements. Required content model: marker* -

database - php search bar when I press submit with nothing in the search bar it shows all the data -