Get Started!

EDIT Mode & App Settings

Using Application / Assembly settings (AKA DataServer MetaData) for simple single value properties, such as Company Description.

Much of the Data & Editing tools focus around the use of listings amnd DataTables with any number of rows.

What about "setting" - check out the Assembly / App level setting document for details on how you can persistently store values that are non-tabular.

In this post we're going to use these same values to persistently store our data, but expose editing of the values via the standard EDIT mode tools.

Some Scenario

Let's say that in the footer of a site, on every page, there's a short (3/4 lines) Company Description which is common.

Of course, we could just use flat ASCX HTML to store the textual content, but what if you wanted to give your customer tools to control the value, save them bothering you when they want it changed.


So lets say the HTML is nothing more than a paragraph :


The CompanyDescription would be something like;

public static string ComapnyDescription { get; }

We're going to flesh out the get in a mo.

To support edit mode we need to add 2 attributes :

  • [data-mercury="simple"] - Tell the editor to enable ContentEditable

  • [data-field="SOME_ELEMENT_ID"] - Where the Editor should store the value for POSTing to the server

We would need something like the following :

<%if( MODE == "EDIT" ){ %>

  <p data-mercury="simple"

  <asp:hiddenfield runat="server"




While strictly speaking leaving the attributes in-place for non EDIT modes won't have any visual impact, personally I'd rather not bloat the code so you'll see wherever I use EDIT mode controls they are ONLY ever wrapped in an if ( MODE == "EDIT").

As you can see, if it's in EDIT mode the extra attributes are added to the paragraph, the value of data-field is set to the ClientID of the HiddenField.

This HiddenField will be the container for the value when POSTed back to the server.

Store it with C# Persistently

Now, the Editor will handle the transfer of the value back & forth to the server when saving, it's time to attach the CompanyDetails property to the Application level persistent store.

// The Hidden field to carry the updated value back to the server
public HiddenField hCompanyDescription;

// CompanyDescription - get only & cached
public static string CompanyDescription {
  get {

    // Use a Cache - this is renderd on every page
    // we don't want a trip to the DB for every request

    if ( string.IsNullOrEmpty(_CompanyDescription ) ) {
      _CompanyDescription = companyDescription;

    return _CompanyDescription;
private static string _CompanyDescription = null;

// DB Key for the Value
private static string companyDescriptionMetaKey = "company-description";

private static string companyDescription {

  get {

    // Get value from store for the Key
    return GeneralApp.DB.WebPages

  set {

    // Set value in store for the Key


Okay, there's a few lines there, it could be reduced but given that this is used on every page the extra effort to cache the value is worth while