views:

29

answers:

1

Hi.

I find this article: http://blog.tomasjansson.com/2010/09/asp-net-mvc-helper-for-active-tab-in-tab-menu/

and i want to this :)

Unfortunately, I was an error:

Opis: Wystąpił błąd w czasie kompilowania zasobu wymaganego do obsłużenia tego żądania. Przejrzyj poniższe szczegłowe informacje o błędzie i zmodyfikuj odpowiednio kod źrdłowy.

Komunikat o błędzie kompilatora: CS1061: Element „System.Web.Mvc.HtmlHelper” nie zawiera definicji „ActiveTab”, a nie odnaleziono metody rozszerzającej „ActiveTab”, która przyjmuje pierwszy argument typu „System.Web.Mvc.HtmlHelper” (czy nie brakuje dyrektywy using lub odwołania do zestawu?).

In line:

<li class="green <%=Html.ActiveTab("Home", "Index") %>"><%= Html.ActionLink("Powitanie", "Index", "Home", new { @class = "green" })%></li>

In my solution i have new project named utils. In this project i add new classes named extensions (public static classes) where i copy all functions from that article. I must add reference to System.Web.Mvc to that project. I attach that Utils project to main project, and i put in site.master line where there is an error.

May I get any sugesstions, or working example??

Regards.

A: 

Unfortunately I don't understand the language in the error message but I suspect the problem comes from the fact that the custom extension method you wrote is not brought into scope. This means that you need to import the namespace into which the static class containing the method in the view (just after the @Page directive):

<%@ Import Namespace="Utils" %>

Utils is the namespace into which you declared the static extensions class. The assembly containing it should also be referenced into the web project if different.

To avoid importing this namespace in each view you would like to use the helper you could declare it in web.config:

<pages>
  <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="Utils" />
  </namespaces>
</pages>
Darin Dimitrov
thx. I just learning mvc :)
dzajdol