lundi 11 septembre 2017

Set razor view variable according to checkbox checked

I am working on an online library using ASP.NET MVC. This is my view model for the library management page:

public class ManageViewModel
{
    public IPagedList<ManageBookViewModel> WholeInventory;
    public IPagedList<ManageBookViewModel> CurrentInventory;
    public bool OldInventoryIsShown { get; set; } = false;
}

In the corresponding view I have a checkbox for whether or not to show the old inventory and a local variable modelList, which I would like to set to Model.WholeInventory if the checkbox is checked and to Model.CurrentInventory otherwise. I use modelList to display a table with all the books and I would need its value to be reset every time I (un)check the checkbox in order for the list to be properly displayed. Is this possible? How would I go about doing this?




Aucun commentaire:

Enregistrer un commentaire