Reputation: 2074
Is there a way to create functions like these in the Razor view engine?
@{
View.Title = "Clients";
private string GetRowClassName(RowStatus status)
{
if (status == Model.SelectedStatus)
return "selected";
return string.Empty;
}
}
Upvotes: 2
Views: 1748
Reputation: 53183
You can do this:
@functions {
private string GetRowClassName(RowStatus status) {
if (status == Model.SelectedStatus)
return "selected";
return string.Empty;
}
}
You could also look into the @helper
syntax but in this case @functions
is probably better.
Upvotes: 6