I am trying to display some data fetched from database into a Textarea of my Razor page. I have tried out something like this. Is this the correct way of displaying the data for view only?
Razor page code snippet:
@if(summaryProjection != null)
{
<div> Seller Data</div>
<textarea>
@summaryProjection.tradeSummary.articleCurrency
</textarea>
}
cs side code:
public Models.SummaryProjection summaryProjection = new Models.SummaryProjection();
protected override async Task OnInitializedAsync()
{
string Id = TID;
summaryProjection = await Http.GetFromJsonAsync<Models.SummaryProjection>($"api/T/summary?Id=" + Id);
}
If it's a block of text you want to display then textarea
is as good a solution as any other (with some css formatting to make it pretty). You will need to add disabled
to prevent editing. In your example you appear to want to display a currency value. for that it's not the best - just use a suitably styled input, again with disabled
set.
<textarea disabled>
@summaryProjection.tradeSummary.articleCurrency
</textarea>