asp.net asp tag helpers not working in a tag

Athenixz 0 Reputation points
2023-04-03T18:33:16.8933333+00:00

asp.net asp tag helpers not working in "a" html tag

@model IEnumerable<Customer>  
@{
    ViewData["Title"] = "Index";
}

<h2 class="display-5 mt-3 mb-1 fw-bold">Customer</h2>
<p class="mb-4">To home page</p>

<a asp-controller="Customer" asp-action="Create" class="btn btn-primary mb-2 mt-3">Create</a>

<table class="table table-bordered table-striped">
    <thead class="table-header bg-primary ">
        <tr>
            <th scope="col">
                Company Name
            </th>
            <th scope="col">
                Contact Person
            </th>
            <th scope="col">
                Email
            </th>
            <th scope="col">Phone</th>
            <th ">Active</th>
            <th>
                Id
            </td>
        </tr>
    </thead>
    @foreach (var obj in Model)
    {
        <tbody>
            <tr>
                <td>
                    @obj.CompanyName
                </td>
                <td>
                    @obj.ContactPerson
                </td>
                <td >
                    @obj.Email
                </td>
                <td >
                    @obj.PhoneNumber 
                </td>
                <td >
                    @obj.Active
                </td>
                <td>
                    <div class="w-75 btn-group" role="group">
                        <a asp-controller="Customer" asp-action="Edit" asp-route-id="@obj.Id"
                           class="btn btn-primary mx-2">Edit</a>
                        <a asp-controller="Customer" asp-action="Delete" asp-route-id="@obj.Id"
                           class="btn btn-danger mx-2">Delete</a>
                    </div>
                </td>
                <td>
                   @obj.Id
                </td>
            </tr>
        </tbody>
    }
</table>

I'm following this tutorial: https://www.youtube.com/watch?v=hZ1DASYd9rk&list=WL&index=15&t=9092s the a tag is not working for my edit and delete buttons are not working. the create is working which confuses me because it is the same. it did work when i was following the tutorial then i saved shut down my laptop and open the project again a few days later and now its just does nothing when i click on the button. the asp-controller="Customer" asp-action="create" does seem greener for the the create link though in visual studio. does anyone have a solution for this.

Developer technologies .NET Other
{count} votes

1 answer

Sort by: Most helpful
  1. Athenixz 0 Reputation points
    2023-04-03T19:55:45.2666667+00:00

    i figured out what the problem is. the <th ">Active</th> was messing up my code.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.