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

ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,505 questions
0 comments No comments
{count} votes

Accepted answer
  1. AgaveJoe 1,495 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 Answers by the question author, which helps users to know the answer solved the author's problem.