mvc4--navigation page using Partialview and passing in model definition navigation

Source: Internet
Author: User

1, in the base class Applicationcontroller definition template page layout needs to use the ViewModel "The actual logic has been implemented, here does not show the code"

Direct

2, right-click on the views-->shared folder

The new section tries to name _topmenuvmodel

Introducing models at the top

Write your corresponding page model below

@foreach can be called directly (Var M10 in Model.topmenulist)

model--"xxx Your ViewModel internal 2-time model defined inside

3, render this part in _layout.cshtml to try to

Direct @Html. Action ("Layoutaction")

The name here is in Figure 1

Layviewmodel can eventually be passed into the _layout.cshtml template page

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.