Answer the question
In order to leave comments, you need to log in
How to put repeating fragments into a separate function in razor mvc?
In many places of the template, the same cycle is repeated.
I wanted to put all this into a function, something like this:
@functions{
// Сильно упрощённый пример
private void OutItems(string GroupName, Iesi.Collections.Generic.ISet<DataRow> Items) {
foreach(var Item in Items) {
@: <div>@Item</div>
}
}
}
Answer the question
In order to leave comments, you need to log in
@helper SomeNameMethod(SomeClass object)
{
//Some RazorMarkup
}
//вызывать @SomeNameMethod(object)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question