名称“Html”当前上下文中不存在
我正在使用一些代码,并且我的 site master 和 Html 标记有问题
我的应用程序基于 c# 中的 asp.net MVC2
我想使用 Html.RenderPartial 来处理 site.master 中的部分视图。 怎么办都行不通。
有什么想法吗?
我包含我的代码供您查看
<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Site.master.cs" Inherits="SportStore.WebUI.Views.Shared.Site" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title><asp:ContentPlaceHolder ID="TitleContent" runat="server" /></title>
<link href="../../Content/Site.css" rel="stylesheet" type="text/css" />
<asp:ContentPlaceHolder ID="head" runat="server">
</asp:ContentPlaceHolder>
</head>
<body>
<div id="header">
<div class="title">Demo test</div>
</div>
<div id="categories">
<% Html.RenderPartial("menu", product); %>
</div>
<div id="content">
<asp:ContentPlaceHolder ID="MainContent" runat="server">
</asp:ContentPlaceHolder>
</div>
</body>
</html>
I am playing up with some code and have problem with my site master and Html tag
My application is based on asp.net MVC2 in c#
I want to use Html.RenderPartial to process my partial view in site.master.
How ever it doesn't work.
Any idea?
i include my code for you to see
<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Site.master.cs" Inherits="SportStore.WebUI.Views.Shared.Site" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title><asp:ContentPlaceHolder ID="TitleContent" runat="server" /></title>
<link href="../../Content/Site.css" rel="stylesheet" type="text/css" />
<asp:ContentPlaceHolder ID="head" runat="server">
</asp:ContentPlaceHolder>
</head>
<body>
<div id="header">
<div class="title">Demo test</div>
</div>
<div id="categories">
<% Html.RenderPartial("menu", product); %>
</div>
<div id="content">
<asp:ContentPlaceHolder ID="MainContent" runat="server">
</asp:ContentPlaceHolder>
</div>
</body>
</html>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我看到您的 master 继承自
SportStore.WebUI.Views.Shared.Site
这是一个自定义类。确保此自定义类派生自 System.Web.Mvc .ViewMasterPage 以便 Html< /a> 属性已定义。I see that your master inherits from
SportStore.WebUI.Views.Shared.Site
which is a custom class. Make sure that this custom class derives from System.Web.Mvc.ViewMasterPage so that the Html property is defined.