@Html.RadioButtonFor(Model => Model.Location, "Location")
@Html.LabelFor(Model=>Model.Location,"Location")
@Html.RadioButtonFor(Model=>Model.Model,"Model")
@Html.LabelFor(Model=>Model.Model,"Model")
@Html.RadioButtonFor(Model=>Model.MovableUnit,"MU")
@Html.LabelFor(Model=>Model.MovableUnit,"MU")
<input id="Location" name="Location" type="radio" value="Location" />
<label for="Location">Location</label>
<input id="Model" name="Model" type="radio" value="Model" />
<label for="Model">Model</label>
<input id="MovableUnit" name="MovableUnit" type="radio" value="MU" />
<label for="MovableUnit">MU</label>
How to have a common name="radiobtn" for all the above Radio buttons? The problem is I want to select only one radio button at a time, but in this case all are selectable at the same time.
Just add the id property to the html-attributes. That will override the default id generated by the editorfor-helper-methode.
The Html. Editor() or Html. EditorFor() extension methods generate HTML elements based on the data type of the model object's property. The following table list the data types and releted HTML elements: DataType.
HiddenFor() is a strongly typed method that is bounded with model class. It communicates and send/receive value to model class properties. Generally it contains 2 parameters; Hidden Field Name which is a model property and Value for Hidden Field.
Just create a dummy property in your Model class like, public string Dummy{get; set;}
@Html.RadioButtonFor(Model => Model.Location, "LOC", new { @Name = "Dummy"})
@Html.RadioButtonFor(Model => Model.Model_Number, "MOD", new { @Name = "Dummy" })
@Html.RadioButtonFor(Model => Model.MovableUnit, "MU", new { @Name = "Dummy" })
Get the value "LOC", "MOD", "MU" using property name 'Dummy'.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With