Reputation: 67285
I have a block of markup I use to link to the next and previous pages. I would like this markup to appear both before and after a table of data.
Is there a way to define this markup only once but show it twice, without using a partial view?
I seem to remember MVC having some sort of page subroutine that creates markup and could be called from anywhere in the page. But I don't recall the syntax for this and can find it anywhere online.
Upvotes: 1
Views: 264
Reputation: 40988
You're looking for @helper
, but it's not supported in ASP.NET Core for reasons explained here.
Right at the end of this discussion, there's a comment that they've added support for HTML code in @functions
blocks. There's an example there too. But that commit was just on March 14, 2019, so it may not have made it to any released version yet. (maybe when ASP.NET Core 3 is released?)
But if that's not available, you could just use a function in @functions
that returns a string of HTML using Html.Raw()
, like the answer here.
Upvotes: 1