c# - What is the difference between a function and a helper in Razor? -
from tutorials i've read, functions contain c# code. case or can have razor syntax in functions? on other side, can have c# code in helpers?
use functions processing , helpers display purposes.
functions used defining c# code, , c# code, pertains page. location perform (preferably small) data operations, etc. granted should in controller or service layer , passed model.
meanwhile helpers actual display. a way write html html without having use plain strings, tagbuilders or other messy c# tactics spit out html.
yes "reusable" others have said. static c# method in page... (rhetorical) why not that?
the point able create/edit html in more natural html environment.
and yes can have c# code inside helpers using regular old @ razor syntax. again should limited display purposes convention. ie: looping through list create elements, etc.
Comments
Post a Comment