views:

10

answers:

1

I want create menu item in asp.net MVC just as like as home and about us.I tried adding following code in "Site.Master" page.

  • <%: Html.ActionLink("Patners","Patner","Home") %>
  • And I've created one view called "patner" by right clicking on "Home" folder in solution explorer and checking the check box of "create strongly-typed view" and view content is "Empty". But it's giving error. How can I add a menu?

    A: 

    When you create a strongly typed view, the controller action rendering this view needs to pass a model:

    public class HomeController: Controller
    {
        public ActionResult Patner()
        {
            var model = new SomeModelTheViewIsStronglyTypedTo();
            return View(model);
        }
    }
    

    And in ~/Views/Home/Partner.aspx:

    <%@ Page 
        Language="C#" 
        Inherits="System.Web.Mvc.ViewPage<Some.SomeModelTheViewIsStronglyTypedTo>" 
    %>
    
    Darin Dimitrov