razor-components

Execute async method on button click in blazor

浪子不回头ぞ 提交于 2020-05-28 13:42:53
问题 I created a "Razor Components" project. I am trying to execute an asynchronous method when pressing a button, but could not figure out the syntax yet. This is my Index.razor : @page "/" @inject GenericRepository<Person> PersonRepository // ... @foreach (var person in persons) { <button onclick="@(() => Delete(person.Id))">❌</button> } @functions { // ... async void Delete(Guid personId) { await this.PersonRepository.Delete(personId); } } When I click the button, nothing happens. I tried

Execute async method on button click in blazor

蓝咒 提交于 2020-05-28 13:42:39
问题 I created a "Razor Components" project. I am trying to execute an asynchronous method when pressing a button, but could not figure out the syntax yet. This is my Index.razor : @page "/" @inject GenericRepository<Person> PersonRepository // ... @foreach (var person in persons) { <button onclick="@(() => Delete(person.Id))">❌</button> } @functions { // ... async void Delete(Guid personId) { await this.PersonRepository.Delete(personId); } } When I click the button, nothing happens. I tried

How to know when EventCallback has been fired?

旧时模样 提交于 2020-05-17 06:59:08
问题 I'm doing some testing with razor components but I have an issue to update a property from the child component to the grand-parent component. I'm using EventCallback to update my parent component when the child component updates a property. It works well for architecture with two levels (ParentComponent/ChildComponent) however, it doesn't work with three levels (GrandParentComponent/ParentComponent/ChildComponent). Let's take an example with three components A, B and C. - A

Razor components vs View Components

泄露秘密 提交于 2020-03-01 05:01:40
问题 I recently upgraded from Asp .NET Core 2.2 to 3.1 and can use Razor Components in razor pages. They look basically like View Components except it uses blazor and everything on the same file. I tried to search but i haven't read anything on documentation that says to use Razor Components instead View Components. So here is the question... What is the point of using Razor Components instead View Components in Razor Pages? Is it better? I know View Components are a bit painful to set because you

Developing Blazor Razor component in VS with dual screens

只愿长相守 提交于 2020-01-29 23:31:30
问题 Is there a way to open Razor component in Visual Studio with environment with dual screens . I'll love to have markup on one screen and @code {} section on other. While MVC developing usually markup is on one screen while JS is on other. Switching to Blazor C# replaces JS,But my mind is still mapped to read markup from one while is code on other. Can we create component with code separated from markp but still connected. 回答1: You can use the code behind with a partial class : MyComponent