Try our conversational search powered by Generative AI!

How to get system.css in MVC Razor

Vote:
 

Hi guys,

I want to get system.css of EpiServer. I searched some topic and I found this

Html.CssLink(EPiServer.Web.PageExtensions.ThemeUtility.GetCssThemeUrl(Page, "system.css"))

But this code cannot work on MVC with razor engine and here is its error

'System.Web.Mvc.HtmlHelper' has no applicable method named 'CssLink' but appears to have an extension method by that name. Extension methods cannot be dynamically dispatched. Consider casting the dynamic arguments or calling the extension method without the extension method syntax.

Could you help me how to get system.css in MVC Razor?

Thank in advance,

#141437
Nov 16, 2015 7:41
Vote:
 

Hi,

Can anyone help to solve this?

Thank,

#141714
Nov 19, 2015 4:44
Vote:
 

It seems lacking a @using to the namespace contains the extensions: EPiServer.Framework.Web.Mvc.Html

#141716
Edited, Nov 19, 2015 7:53
Vote:
 
<p>Hi GP,</p> <p></p> <p>I've already using EPiServer.Framework.Web.Mvc.Html in my code. The problem is method GetCssThemeUrl required object Page, but Page variable I can only get from WebPageBase which have data type is dynamic. I tried to parse it to Page but I didn't know how.</p> <pre class="brush:csharp;auto-links:false;toolbar:false" contenteditable="false">public class ThemeUtility { ... public static string GetImageThemeUrl(Page page, string imagePath); ... }</pre> <pre class="brush:html;auto-links:false;toolbar:false" contenteditable="false">public abstract class WebPageBase : WebPageRenderingBase { ... public override dynamic Page { get; } ... }</pre> <p><img src="http://s13.postimg.org/xbeqv0lc7/abc.png" width="890" alt="" height="349" /><br /><br /></p>
#141717
Nov 19, 2015 8:14
Vote:
 

Hi,

Did you tried to use: @Html.ShellCssLink("system.css")

or calling this as static method: @CssExtensions.ShellCssLink(Html, "system.css") ?

#141733
Nov 19, 2015 10:01
Vote:
 

Hi,

Thank for reply, your code have no error but it generated path"/EPiServer/Shell/8.0.0.0/system.css" which is not found. Existed system.css I want to get is "/App_Themes/Default/Styles/system.css"

#141737
Nov 19, 2015 10:20
Vote:
 

I just used plain HTML tags for system.css (and ToolButton.css). Since they are under App_Themes they are not dependent on the version number, so should (hopefully) be OK after upgrading to new versions.

So I have

<link href="/App_Themes/Default/Styles/system.css" rel="stylesheet" />
<link href="/App_Themes/Default/Styles/ToolButton.css" rel="stylesheet" />

Works for me in CMS 9.2.0.0

Happy to hear if there's a better solution for this.
#142344
Dec 09, 2015 14:56
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.