8

I created a partial view and can't access the Html namespace for HTML Helpers. It's available in the main view. Am I missing something?

enter image description here

EDIT: I should mention that I'm using ASP.NET MVC 5.

Metaphor
  • 6,157
  • 10
  • 54
  • 77
  • Check [this link](http://stackoverflow.com/questions/876412/html-helper-extensions-not-being-found) – lavrik Nov 12 '13 at 14:58
  • Thanks for the link. But I don't see how it's relevant to my question. – Metaphor Nov 12 '13 at 15:04
  • Where does your view located at? – lavrik Nov 12 '13 at 15:21
  • In a sub of Views. Does it matter? – Metaphor Nov 12 '13 at 15:30
  • It can matter, also [this link](http://stackoverflow.com/questions/12041633/razor-views-not-seeing-system-web-mvc-htmlhelper) contains some advice. Or try to restart Visual Studio, sometimes it runs into crazy state... – lavrik Nov 12 '13 at 15:37
  • How are you accessing HtmlHelper from your partial view? Can we see the code? – NKD Nov 12 '13 at 22:28
  • All of the code is in the screenshot. @Html has the cursor next to it and the intellisense dropdown is active. – Metaphor Nov 12 '13 at 22:39
  • If you add it to the View using the @using as it appears in the screenshot, I would restart VS. Not sure if you try that yet. Just thinking out loud. – NKD Nov 13 '13 at 01:09
  • also, how did you add the namespace? (i.e. web.config) – NKD Nov 13 '13 at 01:13
  • Could you try the answer suggested here: http://stackoverflow.com/a/5557503/350933 – ctrlplusb Dec 06 '13 at 15:12
  • You better add the namespace of the helper into the web.config that resides in the views folder and the one in the root folder. – Saravanan Dec 24 '13 at 16:27

1 Answers1

1

check is there a web.config in you views directory and in the web.config

<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" />
  </namespaces>
</pages>
chenZ
  • 920
  • 4
  • 16