asp.net-coreasp.net-core-scaffolding

Buttons in MVC .NET CORE 5 Scaffolding not working, but everything else is fine


I did some scaffolding of some entities and the page looks ok but I can't press any buttons. All pages: Edit, Details, Create etc. look ok but the same problem of no clickable buttons occurs

Here is my _Layout.cshtml code:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>@ViewData["Title"] - NAME WebApp</title>
    <link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css" />
    <link rel="stylesheet" href="~/css/site.css" />
</head>
<body>
    <header>
        <nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bg-white border-bottom box-shadow mb-3">
            <div class="container">
                <a class="navbar-brand" asp-area="" asp-page="/Index">NAME.WebApplication</a>
                <button class="navbar-toggler" type="button" data-toggle="collapse" data-target=".navbar-collapse" aria-controls="navbarSupportedContent"
                        aria-expanded="false" aria-label="Toggle navigation">
                    <span class="navbar-toggler-icon"></span>
                </button>
                <div class="navbar-collapse collapse d-sm-inline-flex justify-content-between">
                    <ul class="navbar-nav flex-grow-1">
                        <li class="nav-item">
                            <a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Index">Home</a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link text-dark" asp-area="" asp-controller="DrugUnits" asp-action="Index">DrugUnits</a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link text-dark" asp-area="" asp-controller="Countries" asp-action="Index">Countries</a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link text-dark" asp-area="" asp-controller="DrugTypes" asp-action="Index">DrugTypes</a>
                        </li>
                    </ul>
                </div>
            </div>
        </nav>
    </header>
    <div class="container">
        <main role="main" class="pb-3">
            @RenderBody()
        </main>
    </div>

    <script src="~/lib/jquery/dist/jquery.min.js"></script>
    <script src="~/lib/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
    <script src="~/js/site.js" asp-append-version="true"></script>

    @await RenderSectionAsync("Scripts", required: false)
</body>
</html>

And the Index.cshtml:

@model IEnumerable<NAME.DataModelCore.Models.DrugType>

@{
    ViewData["Title"] = "Index";
    Layout = "~/Pages/Shared/_Layout.cshtml";
}

<h1>Index</h1>

<p>
    <a asp-action="Create">Create New</a>
</p>
<table class="table">
    <thead>
        <tr>
            <th>
                @Html.DisplayNameFor(model => model.DrugTypeName)
            </th>
            <th></th>
        </tr>
    </thead>
    <tbody>
@foreach (var item in Model) {
        <tr>
            <td>
                @Html.DisplayFor(modelItem => item.DrugTypeName)
            </td>
            <td>
                <a asp-action="Edit" asp-route-id="@item.DrugTypeId">Edit</a> |
                <a asp-action="Details" asp-route-id="@item.DrugTypeId">Details</a> |
                <a asp-action="Delete" asp-route-id="@item.DrugTypeId">Delete</a>
            </td>
        </tr>
}
    </tbody>
</table>

I could not find anybody with this issue. And my coleagues have more or less the exact same code and everything is ok on their part. I have absolutely no idea whatsoever on what else I can try. Thank you!


Solution

  • !SOLVED! In _ViewImports.cshtml I added *@addTagHelper , Microsoft.AspNetCore.Mvc.TagHelpers and also copied it into Views as well