Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Yannick Smits 321 posts 718 karma points
    Dec 06, 2012 @ 19:32
    Yannick Smits
    0

    ClientDependency with 4.11.1

    I tried getting ClientDependency working with the Mvc Renderer. Added mvc section in ClientDependency.config as per http://clientdependency.codeplex.com/wikipage?title=Configuration&referringTitle=Documentation but still getting error 

    'System.Web.Mvc.HtmlHelper<Umbraco.Web.Models.RenderModel>' does not contain a definition for 'RenderJsHere....

    when trying to render (or register) js / css files.

    Does anybody know what piece of code will register the method to the Html helper in razor?

  • Pavel Budik 12 posts 71 karma points c-trib
    Dec 07, 2012 @ 16:40
    Pavel Budik
    1

    Hi Yannick,

    the problem is that default Umbraco installation lacks the ClientDependency.Core.Mvc.dll file. This can be obtained from the ClientDependency hompage. But you will have problems with references, as the assembly ClientDependency.Core.Mvc.dll references System.Web.MVC v4.0.0.0, where Umbraco has only v3.0.0.0. The solution for me was that I donwloaded the CD source and recompiled the ClientDependency.Core.Mvc project with reference to System.Web.MVC.dll in my Umbraco bin directory.

    This was already pointed out in the Umbraco issue tracker.

    Pavel 

  • Yannick Smits 321 posts 718 karma points
    Dec 07, 2012 @ 17:15
    Yannick Smits
    0

    he Pavel, thanks for your reply. I recompilled the MVC source to match the umbraco MVC version (actually it referenced mvc2, not 4). Placed both dll's in my bin but still no luck. Same error as above. Anything special you're doing to register/render your css/js files in cshtml?

  • Pavel Budik 12 posts 71 karma points c-trib
    Dec 08, 2012 @ 00:50
    Pavel Budik
    1

    Ah, I forgot, you also have to add @using ClientDependency.Core.Mvc to your view (that's where the extension method RenderJsHere is defined)...

  • Yannick Smits 321 posts 718 karma points
    Dec 10, 2012 @ 18:43
    Yannick Smits
    0

    Great that seems to work! Can't see how I forgot to add that using statement.

    Now only for every call to RequireCss or RequireJs it is outputting:
    System.Web.Mvc.HtmlHelper`1[Umbraco.Web.Models.RenderModel] 

    Any idea how to prevent that?

  • Pavel Budik 12 posts 71 karma points c-trib
    Dec 10, 2012 @ 21:35
    Pavel Budik
    0

    Sorry for splitting the answer into pieces, but this should really be the last one to make the puzzle complete :-)

    @Html.Raw(Html.RenderCssHere...) 
  • Yannick Smits 321 posts 718 karma points
    Dec 11, 2012 @ 14:51
    Yannick Smits
    0

    it's not the RenderCssHere that is outputting the namespaces it is the RequireCss and RequireJs that do that. Adding @Html.Raw around thouse doesn't help.

  • Pavel Budik 12 posts 71 karma points c-trib
    Dec 11, 2012 @ 14:59
    Pavel Budik
    1

    OK, I forgot. You have to put the RequireCss into the view code. E.g.

     

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage
    @using ClientDependency.Core.Mvc
    @using ClientDependency.Core
    @{
        Layout = null;
        Html.RequiresCss("...");
    }

     

     

  • Yannick Smits 321 posts 718 karma points
    Dec 11, 2012 @ 15:32
    Yannick Smits
    1

    wonderful, finally everything working now! Was quite a challenge. Hope this thread will serve many others to work out the details.

  • Luke Alderton 191 posts 508 karma points
    Jul 09, 2013 @ 18:02
    Luke Alderton
    0

    This worked a treat for me in Umbraco 4.11.6, thanks! :D

  • Christopher Vaught 29 posts 53 karma points
    Nov 12, 2013 @ 22:25
    Christopher Vaught
    0

    Perfect..

Please Sign in or register to post replies

Write your reply to:

Draft