Asp.Net Mvc Checkboxfor default value?
asp.net-mvc, checkbox
Solution
Per the MSDN
A DefaultValueAttribute will not cause a member to be automatically initialized with the attribute's value. You must set the initial value in your code.
Problem
model ``` [DefaultValue(true)] public bool IsActive { get; set; } ``` view ``` @Html.CheckBoxFor(model => model.IsActive) ``` html output and that is my expected ``` <input data-val="true" data-val-required="Yayında alanı boş bırakılmamalıdır!" id="IsActive" name="IsActive" type="checkbox" value="true" class="valid"> ``` but checkbox is not checked. I cant understand why? What am I missing? Thanks.