Html helper does not work with asp.net mvc 3?

Jan 20, 2011 at 9:21 PM

Hi

I get this error when I try to use Html.Combres link with asp.net mvc 3 and razor

Error    3    'System.Web.Mvc.HtmlHelper' does not contain a definition for 'CombresLink' and no extension method 'CombresLink' accepting a first argument of type 'System.Web.Mvc.HtmlHelper' could be found (are you missing a using directive or an assembly reference?)    

In my web.config file I have

 

  
   <pages>
            <namespaces>
                <add namespace="System.Web.Helpers" />
                <add namespace="System.Web.Mvc" />
                <add namespace="System.Web.Mvc.Ajax" />
                <add namespace="System.Web.Mvc.Html" />
                <add namespace="System.Web.Routing" />
                <add namespace="System.Web.WebPages"/>
                <add namespace="Combres.Mvc" />
            </namespaces>
        </pages>



I need to use
    @Html.Raw(Combres.WebExtensions.CombresLink("Jquery"))
In order to get it to work.

Am I doing something wrong or is something needed to make it work with mvc 3?
Coordinator
Jan 22, 2011 at 11:54 AM

Have you imported Combres.Mvc namespace to the view?

@using Combres.Mvc

Jan 22, 2011 at 6:25 PM

I did the imported  through the web.config file.  I will try that later.

Jan 24, 2011 at 5:42 PM

"

Have you imported Combres.Mvc namespace to the view?

@using Combres.Mvc

"

That seems to work but I am wondering why do I have to do that. I though that was the whole point have putting it in the web.config so I don't have to use that statement. I never had to do that in my mvc 2.0 projects.

Jan 24, 2011 at 5:48 PM
Edited Jan 24, 2011 at 5:49 PM

Never mind in mvc 3.0 razor engine you now have to put it in the web.config that is in the views not the root.webconfig

http://stackoverflow.com/questions/4307952/how-do-i-define-usings-in-mvc-3-razor-view-engine-across-entire-site

 

You still seem to need to use html.raw around the html.combresLink when using the razor syntax as it will try to encode it.