Calling all developers! We invite you to provide your input on Feature Experimentation by completing this brief survey.
Calling all developers! We invite you to provide your input on Feature Experimentation by completing this brief survey.
Oooops.... nevermind.
I had my code to display the property in the wrong file. It works now.
But for anyone wondering, this is how I did it.
1) Add a property to your page type. In my case, I named it "CustomCSS".
2) Set property as XHTML string, and under Properties for the Editor, uncheck all boxes so that only code will display.
3) In Header.ascx, add <%= CustomCSS %> where you want it to display.
4) In Header.ascx.cs, I added code to display the string:
protected string CustomCSS
{
get
{
if (CurrentPage.Property["CustomCSS"] != null)
{
return CurrentPage.Property["CustomCSS"].ToWebString();
}
return string.Empty;
}
}
Now you can go into your page and add your custom css into your property. I left it as xhtml string to give the option of either adding some simple css, then I can use <script type="text/css"></script>. But for more complex css, I can add css <link> tags to a custom stylesheet. It would also be easier to find the property if you added a custom tab, and placed the property in that tab.
Hi!
If your just interested in creating a string that should not be editable by an html editor you can just use PropertyLongString instead of PropertyXhtmlString.
Regards
Linus Ekström
EPiServer Development Team
Hi. I have a question. How would I go about adding custom css to the header? For example, I would like to create an XHTML property for Standard Page (page type) and then have the custom css display in the header after the meta tags and stylesheet link tags.
I would turn off all the Properties for Editor, such as Bold, Italics, Underline, Font, Numbered list, etc. I want only the text to display. I know people have used the XHTML property like this before to display custom javascript without having the code rewritten. I think this would work for the css. Or am I wrong?
Is there a way to do this?