I have a 'comments' form in my asp.net core 2.0 MVC application. I want the username in the 'Create New Comment' page to be populated w/ the logged in user. (User must register and log in to post new comment). Same thing w/ the "Date field". This is what I have after scaffolding my comment model :
<form asp-action="Create">
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
<div class="form-group">
<label asp-for="Date" class="control-label"></label>
<input asp-for="Date" class="form-control" />
<span asp-validation-for="Date" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="UserName" class="control-label"></label>
<input asp-for="UserName" class="form-control" />
<span asp-validation-for="UserName" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="YourComment" class="control-label"></label>
<input asp-for="YourComment" class="form-control" />
<span asp-validation-for="YourComment" class="text-danger"></span>
</div>
<div class="form-group">
<input type="submit" value="Create" class="btn btn-default" />
</div>
</form>
I just want the user and the date to be automatically be filled in using data from 'comments' model. Please help.
Thanks! Jeff