Changing Return Types
Change types of return values in Razor functions
By default, the function's return value type is XhtmlDocument
. If you need, you can change it to other types provided they are supported in C1 CMS.
To explicitly specify the return type, use the @returnType
keyword.
@returnType String
Please note that you may need to add namespaces with a @using
directive for some types.
For example, if you want your Razor function to return the value of the XElement
type, make sure to use the System.Xml.Linq
namespace in the .cshtml file.
@using System.Xml.Linq
@returnType XElement
Alternatively, use the type's entire name when declaring it:
@returnType System.Xml.Linq.XElement