MVC5 Classic
wijmenu Step 2 of 3: Creating the Controller

Next, we need to create a controller to return the items from the NorthWND.MDF database’s  view.

To create the controller, follow these steps:

  1. In Solution Explorer expand the Controllers node and then double-click Homecontrollers.cs.
  2. Add the following using statement to the list of directives:
    using [PROJECTNAME].Models;
  3. Now you can specify 1) the Model that is used to populate the menu and 2) the view that will be rendered as a response to the data population. To do this, replace the existing HomeController : Controller class with the following code:
    public class HomeController : Controller
        {
            NORTHWNDEntities northwind = new NORTHWNDEntities();
            public ActionResult Index()
            {
            ViewBag.Message = "Categories";
          var Categories  = northwind.Categories.ToList();
    foreach (Category c in Categories)
    {
    c.Products.Load();
          return View(categories);      
            }
            public ActionResult About()
            {
                return View();
            }
        }
    

Now that we have created the model and the controller, we can create the view, which will consist of a menu and appear on the homepage of the project, in wijmenu Step 3 of 3: Creating the View and Adding Wijmo Widgets.

 

 


Copyright (c) GrapeCity, inc. All rights reserved.

Product Support Forum |  Documentation Feedback