Hi colleagues,
As cjard has advised me, I'm trying to learn Blazor as web development instead of MVC. I'm following this tutorial, but although I'm copying it literally, I can see a few syntax errors which I can't figure out how to solve in the Page I'm working on. I already added the TodoItem class to the project. I tried to run it and there were compiler errors.
I attach a screenshot so you can see the underlined words that are NOT supposed to be errors, but the compiler sees them like so. As we can see, the words 'bind', 'onclick', and 'code' are marked. Why?
I would highly appreciate your help to solve these errors exposed here, and also if you know any better place where to learn Blazor.
Thanks in advance.
Pablo
As cjard has advised me, I'm trying to learn Blazor as web development instead of MVC. I'm following this tutorial, but although I'm copying it literally, I can see a few syntax errors which I can't figure out how to solve in the Page I'm working on. I already added the TodoItem class to the project. I tried to run it and there were compiler errors.
Code of the page in question:
@page "/todo"
<PageTitle>Todo</PageTitle>
<h1>Todo (todos.Count(todo => !todo.IsDone))</h1>
<ul>
@foreach (var todo in todos)
{
<li>@todo.Title</li>
}
</ul>
<input placeholder="Something to do" @bind="newTodo" />
<button @onclick="AddTodo">Add Todo</button>
@code {
private string? newTodo;
private List<TodoItem> todos = new();
private void AddTodo()
{
if (!string.IsNullOrWhiteSpace(newTodo))
{
todos.Add(new TodoItem( { Title = newTodo });
newTodo = string.Empty;
}
}
}
I attach a screenshot so you can see the underlined words that are NOT supposed to be errors, but the compiler sees them like so. As we can see, the words 'bind', 'onclick', and 'code' are marked. Why?
I would highly appreciate your help to solve these errors exposed here, and also if you know any better place where to learn Blazor.
Thanks in advance.
Pablo