lundi 20 avril 2015

Passing model property to checkbox

My model

public class UserVM
{
    public string Email { get; set; }
    public string Password { get; set; } 
    //my windows authentication checkbox property       
    public bool WindowsAuthChk { get; set; }
    //my windows autologin checkbox property  
    public bool AutoLoginChk { get; set; }
}

My view(cshtml)

@model Models.UserVM
@using (Html.BeginForm("Login", "Account", FormMethod.Post, new { id = "signinForm" }))
    {
           <div class="col-md-12">
                @Html.LabelFor(m => m.Email)
            </div>
           <div class="col-sm-6">
                @Html.TextBoxFor(m => m.Email, new { @class = "form-control" })
            </div>

//my checkbox

 <div>@Html.CheckBox("checkWindowsAuth",Model.WindowsAuthChk) @Html.Label("Use windows authentication")</div>

//which is not working, I want to pass my model property WindowsAuthChk to my checkbox above and get the bool value to controller.....I want to know how to pass bool model property to checkbox in @Html.CheckBox

public bool WindowsAuthChk { get; set; }

thanks in advance....




Aucun commentaire:

Enregistrer un commentaire