How to render the checkbox in editor window with corresponding boolean value(i.e)checked or unchecked in MVC 4..?

StackOverflow https://stackoverflow.com/questions/19094077

  •  29-06-2022
  •  | 
  •  

Question

Model: public partial class TBLAppUser { public bool isActive { get; set; } }

View: @Html.CheckBoxFor(u => u.useredit.isActive)

Was it helpful?

Solution

you initialize an instance of TBLAppUser, set the IsActive of that instance to true, and pass that instance to the view. This is quite a simple situation. I think you better look at introductory tutorials found in here asp.net/mvc/overview/getting-started .

following is how your controller action would look like

[HttpGet] 
public ActionResult Index()
{ 
    var mainModel = //what ever the model you represent by u in the view
    mainModel.useredit = new TBLAppUser{ isActive = true}; 
    return View(mainModel); 
} 
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top