Try our conversational search powered by Generative AI!

@Html.PropertyFor unable to refer

Vote:
 

Hi,

I am unable to refer 

@Html.PropertyFor in my cshtml file. I added all the necessary dlls but cshtml is not recognizing the syntax.  Is there anything else I can verify?

Anyone else faced the issue? I am using EPI 7.11 version.

This is the error I am getting
CS1061'HtmlHelper' does not contain a definition for 'PropertyFor' and no extension method 'PropertyFor' accepting a first argument of type 'HtmlHelper'
could be found (are you missing a using directive or an assembly reference?)StartPage\Index.cshtml

I have the below package added to the project.








#149589
Jun 04, 2016 4:25
Vote:
 

Check that you have added the namespace in /views/web.config (or have a @using statement in your .cshtml)

.....
  <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.Routing" />
        <add namespace="EPiServer.Web.Mvc.Html" />
        <add namespace="EPiServer.Shell.Web.Mvc.Html" />
      </namespaces>
    </pages>
  </system.web.webPages.razor>
.....

The PropertyFor extension method in in EPiServer.Web.Mvc.Html

#149590
Jun 04, 2016 10:09
Vote:
 

yes. When I added the reference inside View->Web.config it worked. Thank you

#149600
Jun 05, 2016 5:47
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.