0

We're going through an ASP.Net MVC book and are having trouble with using an extenstion method within our view. The Extension method looks like this:

using System;
using System.Runtime.CompilerServices;
using System.Web.Mvc;

namespace MvcBookApplication
{
  public static class HtmlHelperExtensions
  {
    public static string JQueryGenerator(this HtmlHelper htmlHelper, string formName, object model);
  }
}

We use the extension method in our view like this:

    <%=Html.JQueryGenerator("createmessage", ViewData.Model)%>

The problem is, that line of code says JQueryGenerator isn't a recognized method of HtmlHelper. I believe we've got the correct references set in the web project, but are there other things we can check? There's no using statement for views, is there?

1
  • As Gregoire said, you can either add the MvcBookApplication namespace in the web.config by adding <pages> <namespaces> <add namespace="MvcBookApplication" /> </namespaces> </pages> inside the system.web section in your web.config, or you can either put a <%@ Import Namespace="MvcBookApplication" %> at the beginning of the view that contains the call to the helper method. Commented Mar 29, 2010 at 18:36

1 Answer 1

2

Have you added a reference to MvcBookApplication namespace in your web.config ?

Sign up to request clarification or add additional context in comments.

2 Comments

Sounds like a definite possibility. We'll check it out.
That was it, the namespace wasn't referenced.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.