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
- @helper MyMessage(string message){
- <span class="define your css class">@message</span>
- }
You Can Other Script Like This
- <p>And : @GlobalHelpers.MyMessage("Hello Guys")</p>
Work for Function.
App_Code/GlobalFunctions.cshtml.
- @function{
- public static string Foo(string message){
- return message;
- }
- }
See How Can call a helper with razor code as a parameter
@Message.Helpers.DivThisThat(@<i>inside Content</i>)
No comments:
Post a Comment