I’m working on a Blazor project for some personal learning, and I’ve hit an issue that I can’t seem to figure out the solution to. That being most of my browser-side buttons don’t seem to do anything, likely because they aren’t calling my methods. I’ve checked my syntax, debugged my code, and checked for errors on browser side and I can’t see anything that should be wrong. Everything I can find elsewhere says there shouldn’t be a problem with my code, so I’m here to ask for help. Below is the razor page, ’cause I can’t imagine that the problem is with my CS partial page.
Here’s my razor page
`@page "/deckedit"
@page "/deckedit/{DeckId}"
@using DeckBuilder.Shared
@if (!Saved)
{
<section class="deck-edit">
<h1 class="page-title">@Deck.DeckName</h1>
<EditForm Model="@Deck" OnValidSubmit="@HandleValidSubmit" OnInvalidSubmit="@HandleInvalidSubmit" FormName="DeckEdit">
<ValidationSummary></ValidationSummary>
<div class="form-group row">
<label for="deckname" class="col-sm-3">Deck Name: </label>
<InputText id="deckname" class="form-control col-sm-8" @bind- Value="@Deck.DeckName" placeholder="Enter deck name"></InputText>
<ValidationMessage class="offset-sm-3 col-sm-8" For="@(() => Deck.DeckName)" />
</div>
@if (Deck.DeckId != 0)
{
<ul>
@foreach (string card in Cards)
{
<li>
<li>@card</li>
<button type="button" @onclick="() => RemoveCard(card)">Remove Card</button>
</li>
}
</ul>
}
<div>
<input type="text" @bind="newCard" placeholder="Enter New Card" />
<button type="button" @onclick="AddCard">Add Card</button>
</div>
<button type="submit" class="btn btn-primary edit-btn">Save Deck</button>
@if (Deck.DeckId > 0)
{
<a class="btn btn-danger" @onclick="@DeleteDeck">Delete Deck</a>
}
</EditForm>
</section>
}
else
{
<div class="alert @StatusClass">@Message</div>
}`
TacoTown is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
5
You have chosen the wrong options when you set up your project. You’re page is being rendered statically.
See this answer
What does ‘interactivity location’ mean when creating a Blazor App from a template?
And review the information in this MS Documents article:
https://learn.microsoft.com/en-us/aspnet/core/blazor/components/render-modes?view=aspnetcore-8.0
4