Disable Edit Link based on Condition

Anonymous
2023-09-12T12:10:35.18+00:00

When the Status is open I want the Edit link to be enabled.

It should be disabled or Not show when Status isClosed

(Note the three permitted statuses are Open , Closed )

PatientPortal/Views/Questions/Edit.cshtml

Capturereadonly

Developer technologies | ASP.NET | ASP.NET Core
0 comments No comments
{count} votes

Answer accepted by question author
  1. AgaveJoe 1,510 Reputation points
    2023-09-12T13:58:38.73+00:00

    This is basic Razor syntax. The link you provided does not go to github... But I assume the page is looping over a collection. So just add an "if" to change how the HTML is rendered to whatever makes you happy.

    Razor syntax reference for ASP.NET Core

    @if(item.Status != "Closed")
    {
        <a asp-page="./Edit" asp-route-id="@item.ID">Edit</a>
    }
    
    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

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