Creating Razor Functions in the CMS Console

Create Razor functions in the CMS Console

Note. For information about using Visual Studio to create or edit Razor functions, please see "Creating Razor Functions in Visual Studio".

To create a Razor function in the CMS Console:

  1. In the Functions perspective, select Razor Functions.
  2. Click Add Razor Function on the toolbar.
  3. In the Add Razor Function window, specify:
    • a. Name: The name of the function
    • b. Namespace: The namespace the function will belong to
    • c. Copy from: Keep the option "(New Razor function)" to create a new function, or select an existing Razor function to copy from.
  4. Click OK.

Adding a Razor function

The function will appear under Razor Functions in the left pane, and open in Code Editor in the right pane.

The new function already has some code that will help you get started.

@inherits RazorFunction

@functions {
    public override string FunctionDescription
        get  { return "Shortly describe this function here"; }
    [FunctionParameter(Label = "Heading label here...", Help = "Help text here...", DefaultValue = "Default value here...")]
    public string Heading { get; set; }

    [FunctionParameter(Label = "Article label here...", Help = "Help text here...")]
    public XhtmlDocument Article { get; set; }

    [FunctionParameter(Label = "Image label here...", Help = "Help text here...")]
    public DataReference<IImageFile> Image { get; set; }

<html xmlns="" xmlns:f="">
			<img src="/media(@Image)" style="float:right" />

Note. To learn more about what a new Razor function includes by default, please see "Default Razor Function".