Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

Reusable button - Custom tag helper?

$
0
0

I have this button on about a dozen of my pages:

<button type="button" class="btn btn-outline-primary btn-back" onclick="location.href='/Controller/Action'">Button text</button>

The text of the button will change along with the link but everything else should be the same.  Some options I'm thinking about doing are:

  1. Just writing the html  ~12 times.  
  2. Putting something like this in my _layout page:
@if (ViewBag.Button != null)
{<button type="button" class="btn btn-outline-primary btn-back" onclick="location.href='@ViewBag.ButtonLink'">@ViewBag.Button</button>
}

3. Creating a custom tag helper for it

4. ???

What would you do?  


Viewing all articles
Browse latest Browse all 9386

Trending Articles