Erica
Erica

Reputation: 3

Using Orchard CMS in VS 2012 and my View cshtml file will not compile

I get error indicator lines at @Html.TextBoxFor and @Html.ValidationMessageFor with msg:

"System.Web.WebPages.Html.HtmlHelper does not contain a definition for 'TextBoxFor' and for 'ValidationMessageFor' and no extension method 'TextBoxFor' and for 'ValidationMessagefor' accepting a first argument of type 'System.Web.WebPages.Html.HtmlHelper' could be found..."

I have added using statements directly to the code, confirmed that the references in Web.config are correct, and I have even tried creating an extension method. Nothing seems to help. Please advise. I am new to Razor, so everything is a learning experience.

@model Contact.Settings.Models.ContactSettingsPart

@using System.Web.Mvc.Html

<fieldset>
    <legend>@T("Contact Detail")</legend>

    <div class="editor-label">
        @Html.LabelFor(model => model.ContactFunctionalArea,@T("Contact Name"))
    </div>
    <div class="editor-field">
        @Html.TextBoxFor(model => model.ContactFunctionalArea)
        @Html.ValidationMessageFor(model => model.ContactFunctionalArea)
    </div>
</fieldset>

Upvotes: 0

Views: 362

Answers (2)

Paul Devenney
Paul Devenney

Reputation: 1329

This is non-critical. It should still work fine. Orchard Themes don't normally understand the libraries being used (they're not "real" projects and VS intellisense does not know how to pick this up). The easiest way to ensure no problem at runtime is to include a reference to your models/html helper projects in the Orchard.Web project before building. This will ensure that the dll is in the bin folder for deployment.

I believe that there is supposed to be a way to tell razor to "see" the dlls via web.config (the ones in the theme project or module project), but I've never spent the time to get this working. If you are using Dynamic as your view model, as Orchard seems to encourage (I hate this), then you won't get much intellisense anyway

Upvotes: 1

The Pax Bisonica
The Pax Bisonica

Reputation: 2164

I would check to see if there is a web.config file in your views folder, if not copy one from a different views folder in Orchard.

Upvotes: 0

Related Questions