GlassHtml

GlassHtml is the main class used to render data in Sublayouts and CSHTML files. It's main purpose is to render fields in either editing mode or normal mode depending on the user visiting the page.

Lambda Cache

GlassHtml makes used of a lambda cache to improve the performance of renderings. Typically an Editable method is written as:

@Editable(x=> x.Title)

The cache is used by default but sometimes this can cause problems, for example if you have an Editable method written as follows:

@Editable(x=> Model.Title)

In this scenario it is useful to turn the cache off. This can be achieved on a global level by setting the Glass.Mapper.Sc.UseGlassHtmlLambdaCache to false. This should be done in the GlassMapperScCustom.CastleConfig method of your web project:

public static void CastleConfig(IWindsorContainer container){
    var config = new Config();

    config.UseGlassHtmlLambdaCache = false;

Begin Edit Frame

The BeginEditFrame method allows you to create an Sitecore Edit Frame in the Page Editor. BeginEditFrame comes in two forms, the first form uses the path to the EditFrame buttons in the Sitecore Core database and the Path of the Item you want associated to the Edit Frame. This allows you to use all the features provided by Sitecore Edit Frames, e.g. Delete, Move and Edit Fields.

   @using(BeginEditFrame("/sitecore/content/webedit/buttons", Model.Path)){


    }

Note that BeginEditFrame must be used in a using statement. Using this method you will need to move the Edit Frame configuration items between environments.

The second method allows you to use your model to define a set of fields that can be editted within the Edit Frame. Your model must have either an ID or Path property so that Glass can identify the item you want to associate to the Edit Frame:

   @using(BeginEditFrame(Model, "My Title", x=>x.Field1, x=>x.Field2)){


    }

Behind the scenes Glass creates all the items and configuration need by Sitecore to make this Edit Frame work. This means you don't have to move items between environments.