I want to bind a boolean property to a hidden input controller, but the output html code was error
code as follows:
public class TestModel
{
public bool IsOk { get; set; }
public bool IsSuccess { get; set; }
}
public class HomeController : Controller
{
public ActionResult Index()
{
return View(new TestModel { IsOk = false, IsSuccess = true });
}
}
<h2>Index</h2>
<p>@Model.IsOk</p>
<p>
<input type="hidden" value="@Model.IsOk" />
</p>
<p>
<input type="hidden" value="@Model.IsSuccess" />
</p>
Html Output
<h2>Index</h2>
<p>False</p> //works
<p>
<input type="hidden" /> //where is value?
</p>
<p>
<input type="hidden" value="value" /> //wath's this?
</p>
But if i use ToString(), all above works well, so is it my mistake?