我收到此错误(system.web.mvc.webviewpage< tmodel> .model.get返回null。)

编程入门 行业动态 更新时间:2024-10-26 20:24:52
本文介绍了我收到此错误(system.web.mvc.webviewpage< tmodel> .model.get返回null。)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

Home Controller public ActionResult Index() { MenuModel ObjMenuModel = new MenuModel(); ObjMenuModel.MainMenuModel = new List<MainMenu>(); ObjMenuModel.MainMenuModel = GetMainMenu(); ObjMenuModel.SubMenuModel = new List<SubMenu>(); ObjMenuModel.SubMenuModel = GetSubMenu(); return View(ObjMenuModel); } public List<MainMenu> GetMainMenu() { List<MainMenu> ObjMainMenu = new List<MainMenu>(); ObjMainMenu.Add(new MainMenu { ID = 1, MainMenuItem = "Home", MainMenuURL = "#" }); ObjMainMenu.Add(new MainMenu { ID = 2, MainMenuItem = "System Setup", MainMenuURL = "#" }); return ObjMainMenu; } public List<SubMenu> GetSubMenu() { List<SubMenu> ObjSubMenu = new List<SubMenu>(); ObjSubMenu.Add(new SubMenu { MainMenuID = 2, SubMenuItem = "Customer Information", SubMenuURL= "Employer" }); ObjSubMenu.Add(new SubMenu { MainMenuID = 2, SubMenuItem = "Chart Of Accounts", SubMenuURL = "CompanyProfile" }); return ObjSubMenu; } My Model namespace Ron_Financial_Management_System.Models { public class MenuModel { public List<MainMenu> MainMenuModel { get; set; } public List<SubMenu> SubMenuModel { get; set; } } public class MainMenu { public int ID; public string MainMenuItem; public string MainMenuURL; } public class SubMenu { public int MainMenuID; public string SubMenuItem; public string SubMenuURL; } }

我的布局视图

My Layout view

<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>@ViewBag.Title</title> <link href="~/Content/Site.css" rel="stylesheet" type="text/css" /> <script src="code.jquery/jquery-latest.min.js" type="text/javascript"></script> <link href="~/Content/bootstrap.min.css" rel="stylesheet" /> <link rel="shortcut icon" type="image/x-icon" href="~/Ron.ico" /> <script src="~/Scripts/modernizr-2.6.2.js"></script> <link href="~/Content/style.css" rel="stylesheet" type="text/css" /> <script src="canvasjs/assets/script/canvasjs.min.js"></script> <script src="~/Scripts/jquery-1.12.4.min.js"></script> <link href="~/Content/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css" /> @*<script src="@url.Content("~/Scripts/jquery-1.8.3.js")" type="text/javascript"></script> <script src="@url.Content("~/Scripts/jquery-ui.min.js")" type="text/javascript"></script>*@ <script src="../../Scripts/script.js" type="text/javascript"></script> <script type="text/javascript"> $(document).ready(function () { $("#accordian h3").click(function () { $("#accordian ul ul").slideUp(); if (!$(this).next().is(":visible")) { $(this).next().slideDown(); } }); }); </script> </head> <body> @using System.Web.Optimization @model Ron_Financial_Management_System.Models.MenuModel @using (Html.BeginForm("_Layout", "Shared")) { <div id="wrapper"> <div id="menuTop"> <table> <tr> <td align="center"><a href="@Url.Action("Logout","Login")">Logged In As:</a> </td> <td align="center"><a href="@Url.Action("Logout","Login")">Last Login:</a></td> <td align="center"><a href="@Url.Action("Logout","Login")">Logout</a> </td> </tr> </table> </div> <div id="menuLogo"> Logo </div> <div id="banner"> <img id="img_logo" alt="Logo" src="@Url.Content("~/Content/Images/RFMS_Brand.png")" /> </div> <div id="columnLeft"> <div id="accordian"> <ul> <li> @{ if(Model.MainMenuModel==null){ <span>no items found</span> } else { foreach (var MenuItem in Model.MainMenuModel) { var SubMenuItem = Model.SubMenuModel.Where(m => m.MainMenuID == MenuItem.ID); <h3><a href="@MenuItem.MainMenuURL"> @MenuItem.MainMenuItem </a></h3> if (SubMenuItem.Count() > 0) { <ul> @foreach (var SubItem in SubMenuItem) { <li><a href='@SubItem.SubMenuURL'>@SubItem.SubMenuItem</a></li> } </ul> } } } } </ul> </div> <br /> </div> <div id="content"> @RenderBody()</div> <div id="menuBottom" aling="center"> © Copyright @DateTime.Now.Year Ron Technologies Ltd </div> </div> } @Scripts.Render("~/bundles/jquery") @Scripts.Render("~/bundles/bootstrap") @RenderSection("scripts", required: false) </body> </html>

My Emplyer view

My Emplyer view

@model Ron_Financial_Management_System.Employer @*@model Ron_Financial_Management_System.Models.MenuModel*@ @{ Layout = "~/Views/Shared/_Layout.cshtml"; } <h4>Employer</h4>

我是什么尝试过:

What I have tried:

Can someone kindly guide me on what could be the problem?

当我点击下拉菜单检查雇主链接时我得到上述错误,我已经尝试了所有方法但没有成功,请帮助 注意:我正在接受此行在我的布局视图中(

when i click at the drop down menu examle the employer link i get the above error, i have tried all means without success kindly help Note: i am geting the at this line in my layout view (

foreach (var MenuItem in Model.MainMenuModel)

推荐答案

(文件).ready(function(){ (document).ready(function () {

(#accordian h3)。click(function(){ ("#accordian h3").click(function () {

(#accordian ul ul)。slideUp(); if(! ("#accordian ul ul").slideUp(); if (!

更多推荐

我收到此错误(system.web.mvc.webviewpage&lt; tmodel&gt; .model.get返回null。)

本文发布于:2023-11-10 00:34:01,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1573870.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:错误   mvc   webviewpage   web   amp

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!