AspNetItem layout renderer

Julian Verdurmen edited this page Jan 8, 2016 · 1 revision
Clone this wiki locally

ASP.NET Item variable. Use this layout renderer to insert the value of the specified variable stored in the ASP.NET HttpContext.Current.Items dictionary.

Supported in .NET and Mono

Configuration Syntax

${aspnet-item:variable=String;evaluateAsNestedProperties:boolean}

Parameters

Rendering Options

  • variable - Variable name.
  • EvaluateAsNestedProperties - boolean. Default: false. Evaluate the as nested properties. The dots in the variable are special interpreted. See example below.

Examples

You can set the value of an ASP.NET Item variable by using the following code:

Example usage of ${aspnet-item}

HttpContext.Current.Items["myvariable"] = 123;
HttpContext.Current.Items["stringvariable"] = "aaa BBB";
HttpContext.Current.Items["anothervariable"] = DateTime.Now;

${aspnet-item:variable=myvariable} - produces "123"
${aspnet-item:variable=anothervariable} - produces "01/01/2006 00:00:00"
${aspnet-item:variable=anothervariable:culture=pl-PL} - produces "2006-01-01 00:00:00"
${aspnet-item:variable=myvariable:padding=5} - produces "  123"
${aspnet-item:variable=myvariable:padding=-5} - produces "123  "
${aspnet-item:variable=stringvariable:upperCase=true} - produces "AAA BBB"