Hello,
I am using ASP.NET Core Razor Pages 6.0.
In a .cshtml file, I have a simple element like this:
<div class="mb-3 mt-3">
<label asp-for="User.firstname" class="form-label">First Name:</label>
<input asp-for="User.firstname" class="form-control" placeholder="First Name">
</div>
How do I access & change the above <input> element inside the 'OnGet' or 'OnPost' methods?
I need to do so as I want to add a certain class to that <input> element, or make it readonly (depending on certain conditions in my server code).
In older versions of .NET, this was possible by giving an HTML element an id, and write runat="server". Then, one could access the element in the code-behind via its id and manipulate it. How is it done now?
Should I not be able to do the same because of the asp-for tag helper which I used? But how?
Thank you for your help!