0

This may feel wired but it's taking me no where

Am getting Error at HTML Extesions

enter image description here

At @Html and go to definition it's reference from

enter image description here

But the Actual reference should be from

enter image description here

More interesting thing is am not getting extension properties eg : @Html.Action , @Html.ActionLink & more

enter image description here

Have already checked with Web.config file and it's seems fine Cross verified :

https://stackoverflow.com/questions/24147846/system-web-webpages-html-htmlhelper-does-not-contain-a-definition-for-sitecor

'System.Web.WebPages.Html.HtmlHelper' does not contain a definition for 'ActionLink

Community
  • 1
  • 1
Vinod
  • 596
  • 2
  • 10
  • 28
  • 1
    Used two steps to slove this : 1. Clear the following temporary files : C:\WINDOWS\Microsoft.NET\Framework\v4.X.XXXX\Temporary ASP.NET Files\ 2. Update VS throught NugePackage... – Vinod Jan 08 '15 at 06:33

1 Answers1

0

You should use MvcHtmlString class to implement razor extenuation method. like this.

I'have implemented it for Spanfor properties. you can implement by using this approach

below code will help you as an idea.

public static MvcHtmlString SpanFor<TModel, TProperty>(this HtmlHelper<TModel> html, Expression<Func<TModel, TProperty>> expression, object htmlAttributes)
        {
            var valueGetter = expression.Compile();
            var value = valueGetter(html.ViewData.Model);

            var span = new TagBuilder("span");
            span.MergeAttributes(new RouteValueDictionary(htmlAttributes));
            if (value != null)
            {
                span.SetInnerText(value.ToString());
            }

            return MvcHtmlString.Create(span.ToString());
        }

I hope this will help you.

Prashant Mehta
  • 484
  • 2
  • 11
  • 30