Monday, 21 October 2013

Global Helper Use In Umbraco

Another way to tructure the razorness in different files is to use global helpers, that is .cshtml files stored in the App_Code folder.

App_Code/GlobalHelpers.cshtml

  1. @helper MyMessage(string message){
  2. <span class="define your css class">@message</span>
  3. }

You Can Other Script Like This

  1. <p>And : @GlobalHelpers.MyMessage("Hello Guys")</p>

Work for Function.

App_Code/GlobalFunctions.cshtml.

  1. @function{
  2. public static string Foo(string message){
  3.     return message;
  4.   }
  5. }

See How Can call a helper with razor code as a parameter

  1. @Message.Helpers.DivThisThat(@<i>inside Content</i>)

No comments:

Post a Comment