本文介绍了部分视图菜单-发送信息以查看的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

这就是我尝试获取包含类的视图的方式.我得到它的方式是通过编写:

That's how I try to get a view that includes a class with. The way I get it on it is by writing:

@Html.Partial("View/ViewBar_Info/Menu")

如果我正在执行普通的MVC视图,则可以执行此操作.但这是因为我必须获得通过数据库控制的菜单.因此,我尝试在这里执行此操作.

If I'm doing an ordinary MVC view, I can do that. but that's because I have to get the menu that is being controlled via the database. Therefore, I try to do this here.

如何调用该视图?

错误文字:

生成的代码缺少一个或多个编译参考.确保您的项目引用了"Microsoft.NET.Sdk.Web",并且"PreserveCompilationContext"属性未设置为false.

Generated Code One or more compilation references are missing. Ensure that your project is referencing 'Microsoft.NET.Sdk.Web' and the 'PreserveCompilationContext' property is not set to false.

更新EIDT:

我是通过_Layout.cshtml

I make this from _Layout.cshtml

@Html.Partial("View/ViewBar_Info/Menu.cshtml")

在Menu.cshtml中:

in the Menu.cshtml:

@page
@model NewWebsite_SITE_2018.Pages.View.ViewBar_Info.MenuModel

@foreach (var item in Model.GetListMenu)
{
    <a>@item.Name</a>
}

现在出现错误:

我想做的是在我的布局中,所以我将调用菜单,因此位于单个页面上.

What I'm trying to do is in my layout, so I'll call my menu so come on the single page.

推荐答案

第一个问题是2.0.3版中修复的Razor预编译问题. https://github.com/dotnet/core-setup/issues/2981

First problem has been in Razor precompilation issue that fixed in 2.0.3https://github.com/dotnet/core-setup/issues/2981

第二

当您调用粒子时,如果不发送剃刀,则应向其发送正确的模型

When you call your partical you should send correct model to it if you not send razor try to send current model of view

发送现有模型

@ Html.Partial("View/ViewBar_Info/Menu.cshtml",yourMenuModel)

或创建新

@ Html.Partial("View/ViewBar_Info/Menu.cshtml",新的NewWebsite_SITE_2018.Pages.View.ViewBar_Info.MenuModel())

或修改非必需模型的视图

or modify your view for non required model

@{
var menuModel = new NewWebsite_SITE_2018.Pages.View.ViewBar_Info.MenuModel();
}

@foreach (var item in menuModel.GetListMenu)
{
    <a>@item.Name</a>
}

这篇关于部分视图菜单-发送信息以查看的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 18:03