prabhu p

prabhu p

  • NA
  • 181
  • 115k

regarding Checkbox in mvc

Jan 16 2018 4:27 AM
i have a checkbox in view based upon  database data(boolean) it should be checked and unchecked when that view loading 
 
What i did
in view
@model RelSystem.DL.Model.Admin.UserAccount
@{
ViewBag.Title = "UserAccount";
}
<h2>UserAccount</h2>
 
@using (Html.BeginForm())
{
@Html.AntiForgeryToken()
<div class="container customdiv">
<ul class="list-group">
<li class="list-group-item">
Super User
<div class="material-switch pull-right col-lg-5">
@Html.CheckBoxFor(model => model.SuperUsrChk)
<label for="SuperUsrChk" class="label-primary"></label>
</div>
</li>
</ul>
</div>
In contoller action 
public ActionResult UserAccount()
{
UserAccount UA = new UserAccount();
UA.SuperUsrChk = true; //Checkbox model
return View(UA);
}
Model
 
public bool SuperUsrChk { get; set; }
public bool RequestorUsrChk { get; set; }
 
I am getting output as i need , please help on this 
 
 
 
 
 
 

Answers (1)