locked
Store grid state when click on menu RRS feed

  • Question

  • User-257070954 posted

    Hi All,

                In my application i had two menu's and two pages. When i  click first menu it will load data in grid . When i click second menu i want to save first menu grid data in localstorage. if i click first menu again i want to load data from local storage, same time i want to store second menu data in local storage. These grids are in different pages. How can i achive this?

    Tuesday, July 30, 2019 9:59 AM

All replies

  • User-1038772411 posted

    Hello, binustrat

    you can use TempData for keep and peek data in asp.net mvc.

    How to user Tempdata please refer below code and reference link :

    //Controller Action 1 (TemporaryEmployee)
     public ActionResult TemporaryEmployee()
    {
                    Employee employee = new Employee
                    {
                            EmpID = "121",
                            EmpFirstName = "Imran",
                            EmpLastName = "Ghani"
                    };
                    TempData["Employee"] = employee;
                    return RedirectToAction("PermanentEmployee");
    }
    
     //Controller Action 2(PermanentEmployee)
     public ActionResult PermanentEmployee()
    {
                   Employee employee = TempData["Employee"] as Employee;
                   return View(employee);
     }

    Reference link :

    https://www.codeproject.com/Articles/786603/Using-TempData-in-ASP-NET-MVC

    Thanks

    Tuesday, July 30, 2019 10:18 AM
  • User-1696960412 posted

    First, we need to track the click on the add button and check that the input field is not empty:$ ('# add'). click (function () {var Description = $ ('# description'). val (); if ($ ("# description"). val () == '') {$ ( '#alert'). html ("<strong> Warning! </strong> You left the to-do empty"); $ ('# alert'). fadeIn (). delay (1000) .fadeOut (); return false;} This code checks the value of the text input and, if it is empty, shows an error and returns false so that the rest of the code does not execute and the item is not added to the list. Next, we need to add the case to the list. We will use the prepend method, i.e. items will be added to the top of the list. Then the whole list is stored in local storage. You can read on this blog app like wish how to solve the problem further. Or try other options.

    Tuesday, August 27, 2019 11:47 AM