[英]@Html.EditorFor is Not Available inside the View
I am using Visual Studio 2013 Web Express. 我正在使用Visual Studio 2013 Web Express。 In my ASP.NET MVC application view I cannot call or even see the @Html.EditorFor method.
在我的ASP.NET MVC应用程序视图中,我无法调用甚至看不到@ Html.EditorFor方法。 The intellisense never pops it up.
智慧永远不会弹出。
Any ideas? 有任何想法吗?
EDITED: Same goes with @Html.BeginForm. 编辑:@ Html.BeginForm也是如此。 The method never pops up!
该方法永远不会弹出!
It sounds like the namespace is not available. 听起来命名空间不可用。 In the first instance, try adding
首先,尝试添加
@using System.Web.Mvc.Html
at the top of your view to see if that helps. 在视图顶部查看是否有帮助。 If it does, then there is probably a problem with your View specific
Web.config
. 如果是这样,则您的特定于View的
Web.config
可能存在问题。 In the root of your Views
folder there should be a Web.config
file. 在
Views
文件夹的根目录中应该有一个Web.config
文件。 Note that if you use Areas then there should be one of those in each Views
folder. 请注意,如果您使用“区域”,则每个“
Views
文件夹中应该有一个。
Inside that Web.config
there should be a section like the following: 在该
Web.config
,应该有一个类似于以下内容的部分:
<configuration>
...other stuff...
<system.web.webPages.razor>
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<pages pageBaseType="System.Web.Mvc.WebViewPage">
<namespaces>
<add namespace="System.Web.Mvc" />
<add namespace="System.Web.Mvc.Ajax" />
<add namespace="System.Web.Mvc.Html" />
<add namespace="System.Web.Optimization"/>
<add namespace="System.Web.Routing" />
<add namespace="WebApplication1" />
</namespaces>
</pages>
</system.web.webPages.razor>
...other stuff...
</configuration>
Essentially that section is the equivalent of adding using
statements inside each view. 从本质上讲,该部分等效于在每个视图中添加
using
语句。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.