Inhalte aufrufen

Profilbild

How to reference to HTML Helper Extension in Plugins


  • Bitte melden Sie sich an, um eine Antwort zu verfassen.
2 Antworten zu diesem Thema

#1 Xuan Nguyen

Xuan Nguyen

    Newbie

  • Members
  • Punkt
  • 9 Beiträge

Geschrieben: 15 February 2017 - 14:34

Dear All

I create new Html Helper Extension in my Plugin. But in view it not define

 

Compiler Error Message: CS1061: 'System.Web.Mvc.HtmlHelper<dynamic>' does not contain a definition for 'IsSelected' and no extension method 'IsSelected' accepting a first argument of type 'System.Web.Mvc.HtmlHelper<dynamic>' could be found (are you missing a using directive or an assembly reference?)

 

I add namespace into web.config, use @using NamespaceofHtmlHeplerExtendsion but still not been. So who can help me? Thanks alot.



#2 Marcus Gesing

Marcus Gesing

    SmartStore AG

  • Administrators
  • 3801 Beiträge

Geschrieben: 15 February 2017 - 15:50

Example:
using System.Web.Mvc;

namespace MyCompany.MyPlugin
{
  public static class HtmlHelperExtensions
  {
    public static string MyExtensionMethod(this HtmlHelper helper, ...
And add @using MyCompany.MyPlugin; to your view. Usage @Html.MyExtensionMethod
 

  • Xuan Nguyen gefällt das

Marcus Gesing

Smartstore AG


#3 Xuan Nguyen

Xuan Nguyen

    Newbie

  • Members
  • Punkt
  • 9 Beiträge

Geschrieben: 15 February 2017 - 18:00

Thanks you very much! I've fixed it.