Execute Other Functions

Execute other functions in Razor functions

There are two helper methods that allows you to execute other functions in your Razor functions.

To insert the output of other functions, use the Html.C1().Function helper method, which has three overloads.

The first parameter must be the name of the function to call. The second parameter is optional and is a list of parameters passed as either an object new {Param1=1, Param2=2}, or a Dictionary <string, string> {"Param1", 1}, {"Param1", 2}}.

To execute a function that does not return any output, use the Functions.ExecuteFunction helper method.


For the example of both these usage scenarios, please see ExecuteOtherFunction.cshtml (below or at ~\App_Data\Razor\Examples\ExecuteOtherFunctions.cshtml on your site).

@inherits CompositeC1Contrib.RazorFunctions.CompositeC1WebPage
@using CompositeC1Contrib.RazorFunctions;


@Html.C1().Function("Examples.ColorCube" , new { MinimumRed = 255 }) 

<br /> <br />

@Html.C1().Function("Examples.ColorCube" , new { MinimumGreen = 255, BorderWidth = 10 }) 

<br /> <br />

    new  Dictionary<string , object>() 
        { "MinimumRed", 40 },
        { "BorderWidth", 30 }