Try our conversational search powered by Generative AI!

Henrik Fransas
Nov 20, 2015
  2640
(1 votes)

PropertyAppSettings, a great but kind of hidden build in function in Episerver

This function has been built in for a long time, but the documentation of it is very hidden, so I hope I with this post will inspire more people to use it.

This is very usefull if you like to have a selectbox with hard values in, meaning that the content of the select box will not change other than when you deploy the next time.

The property is called PropertyAppSettings and it works like this.

First create a new appsettings in web.config that looks like this

<add key="BackgroundColor" value="White;#fff|Black;#000|Blue;#0276FD"/>

And then in your content type definition you just write

[Display(Name = "Background Color",
   Description = "Select the background color of the page",
   Order = 1)]
[BackingType(typeof(PropertyAppSettings))]
public virtual string BackgroundColor { get; set; }

The important thing is that your property must be named exactly the same as your key in the appsettings. After that you will have a property that will look something like this in the editor

Image example.png

Hopes this help someone.

Nov 20, 2015

Comments

Arild Henrichsen
Arild Henrichsen Nov 20, 2015 01:09 PM

This has been built-in since at least Epi 5 :-)

FYI there is also a PropertyAppSettingsMultiple that works in the same way, but renders check boxes. (http://world.episerver.com/documentation/Class-library/?documentId=cms/9/7CB200B2)

In your node in web.config, define the key/value pairs like this:

<>appSettings>
    <>add key="Color" value="White;#ffffff|Black;#000000|Red;#ff0000" />
appSettings>

Henrik Fransas
Henrik Fransas Nov 20, 2015 02:03 PM

True Arild, as I wrote, a long time, but still many developers seems not to know about it and there are no examples on it that I can find in the documentation either.

Yeah, I have never tried it, but read about it.

Please login to comment.
Latest blogs
Optimizely and the never-ending story of the missing globe!

I've worked with Optimizely CMS for 14 years, and there are two things I'm obsessed with: Link validation and the globe that keeps disappearing on...

Tomas Hensrud Gulla | Apr 18, 2024 | Syndicated blog

Visitor Groups Usage Report For Optimizely CMS 12

This add-on offers detailed information on how visitor groups are used and how effective they are within Optimizely CMS. Editors can monitor and...

Adnan Zameer | Apr 18, 2024 | Syndicated blog

Azure AI Language – Abstractive Summarisation in Optimizely CMS

In this article, I show how the abstraction summarisation feature provided by the Azure AI Language platform, can be used within Optimizely CMS to...

Anil Patel | Apr 18, 2024 | Syndicated blog

Fix your Search & Navigation (Find) indexing job, please

Once upon a time, a colleague asked me to look into a customer database with weird spikes in database log usage. (You might start to wonder why I a...

Quan Mai | Apr 17, 2024 | Syndicated blog

The A/A Test: What You Need to Know

Sure, we all know what an A/B test can do. But what is an A/A test? How is it different? With an A/B test, we know that we can take a webpage (our...

Lindsey Rogers | Apr 15, 2024

.Net Core Timezone ID's Windows vs Linux

Hey all, First post here and I would like to talk about Timezone ID's and How Windows and Linux systems use different IDs. We currently run a .NET...

sheider | Apr 15, 2024