# Passing a true/false value to a model used in a controller

This passes the value of true/false to model which I can use in my controller.

How can this be cleaned up?

<div data-role="fieldcontain" class="inline-toggle">
<label for="IsAuto">Auto <a href="#"><img class="smallInfo" src="/sites/dev-demo/mobile/assets/images/info@2x.png"></a>:</label>
<select name="IsAuto" class="togglehidden" id="IsAuto" data-role="slider" data-hidden-id="#autohidden">
<option value="false">No</option>
<option value="true">Yes</option>
</select>
@Html.HiddenFor(m => m.IsAuto, new { id = "#IsAuto", value="#IsAuto" })
<input type ="hidden" name ="autorel" id="autorel" value="@(Model.IsAuto = "#IsAuto".AsBool())" />


None. However, it has several issues. Here it is, indented differently to avoid horizontal scroll:

<div data-role="fieldcontain" class="inline-toggle">
<label for="IsAuto">Auto
<a href="#">
<img class="smallInfo" src="/sites/dev-demo/mobile/assets/images/info@2x.png">
</a>:
</label>
<select name="IsAuto"
class="togglehidden"
id="IsAuto"
data-role="slider"
data-hidden-id="#autohidden">
<option value="false">No</option>
<option value="true">Yes</option>
</select>
@Html.HiddenFor(m => m.IsAuto, new { id = "#IsAuto", value="#IsAuto" })
<input
type ="hidden"
name ="autorel"
id="autorel"
value="@(Model.IsAuto = "#IsAuto".AsBool())" />

1. Where is the closing tag for div?

2. What do you use, XHTML or HTML5? In the first case, you should close img. In the second case, you shouldn't close the last input.

3. "#IsAuto".AsBool() always returns false, since "#IsAuto" is never equal to "true".

4. Why are you assigning a value to a property of your model in a view in the last line? Maybe you expected Model.IsAuto == ...?

5. An id of the hidden field which starts by # is weird.

6. If you care about naming conventions, m is a poor name for a variable. Basically, any person who have never used ASP.NET MVC before wouldn't be able to know that it refers to a model.

7. Given the actual syntax for the hidden field, wouldn't it be easier to simply write it in plain HTML?