Trying to associate custom CSS with a custom view...

Editor
Oct 25, 2011 at 5:31 PM

I'm working on some custom views (eg "MyDomainObject/ObjectEdit.aspx"), but which inherit (like the generic views) from Site.WithServices.Master (ie the MasterPageFile="~/Views/Shared/Site.WithServices.Master" attribute is present).

For the custom view, I have some custom CSS, and would like to put it into a Content/MyDomainObject/ObjectEdit.css file and have it loaded selectively by the master file.  

I was thinking that a contentPlaceHolder might be the right way to go about this, however, I'm having problems getting this to work...

* Content/MyDomainObject/ObjectEdit.css is my custom CSS

* Views/Shared/Site.WithServices.Master has:

    <!-- custom css start -->    <asp:ContentPlaceHolder ID="CustomCssContent" runat="server" />    <!-- custom css end -->

* Views/MyDomainObject/ObjectEdit.aspx has:

<asp:Content ID="Content3" ContentPlaceHolderID="CustomCssContent" runat="server">
  <link rel="stylesheet" type="text/css" href="../../Content/Communication/ObjectEdit.css" />
</asp:Content>

 

Will this not work?  Or am I just missing something silly?

Thx

Dan

Coordinator
Oct 26, 2011 at 8:40 AM

I don't think we've tried this - I've just added any extra css files directly at the master page level. I can't see anything there specific to Naked Objects so you may want to ask on a ASP.NET MVC forum.