OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

Using Radio Buttons as Input for Boolean Model Property ASP.NET MVC

  • Thread starter Thread starter Na...
  • Start date Start date
N

Na...

Guest
I would like to use radio buttons to indicate whether or not something is in need of repair on my form.

I have already referenced this question and used the answer offered by Ben Cull, but I would like the user to have to click on one of the radio buttons in order to be able to submit the form. In his answer, one of the two options will always be selected, meaning that you can submit the form without having had to select one of the options directly. Here is an example of what I have at the moment:

Code:
            <div class="form-group">
                <label class="control-label">In Good Condition</label>
                <br />
                @Html.RadioButtonFor(model => model.InGoodCondion, "true") Good Condition
                <br />
                @Html.RadioButtonFor(model => model.InGoodCondion, "false") Needs Maintenance
            </div>

It is also important that the input remain radio buttons.
<p>I would like to use radio buttons to indicate whether or not something is in need of repair on my form.</p>
<p>I have already referenced <a href="https://stackoverflow.com/questions...o-radio-buttons-with-strongly-bound-model-mvc">this</a> question and used the answer offered by Ben Cull, but I would like the user to have to click on one of the radio buttons in order to be able to submit the form. In his answer, one of the two options will always be selected, meaning that you can submit the form without having had to select one of the options directly.
Here is an example of what I have at the moment:</p>
<pre><code> <div class="form-group">
<label class="control-label">In Good Condition</label>
<br />
@Html.RadioButtonFor(model => model.InGoodCondion, "true") Good Condition
<br />
@Html.RadioButtonFor(model => model.InGoodCondion, "false") Needs Maintenance
</div>
</code></pre>
<p>It is also important that the input remain radio buttons.</p>
Continue reading...
 
Top