blazor

The type or namespace IJSObjectReference could not be found

≯℡__Kan透↙ 提交于 2020-12-15 05:25:14
问题 I just started Blazor. I am trying to invoke a javascript function from a razor partial class. using Microsoft.JSInterop; public partial class Counter { [Inject] IJSRuntime js { get; set; } IJSObjectReference module; [JSInvokable] public async Task IncrementCount() { module = await js.InvokeAsync<IJSObjectReference>("import", "./js/Counter.js"); await module.InvokeVoidAsync("displayAlert", "New message"); } } I get the following error The type or namespace IJSObjectReference could not be

Blazor client WASM form validation in component not working

﹥>﹥吖頭↗ 提交于 2020-12-15 05:23:33
问题 Im having trouble getting from validation to work properly in a Blazor WASM client application. Encapsulating an InputText element to a component for compact layout does no longer perform validation that is executed correctly otherwise. using model like public class Customer { [Required] [StringLength(100) public string customerName {get; set;} = ""; } in a form of <EditForm Model=@customer> <DataAnnotationsValidator /> <ValidationSummary /> <div class="form-row"> <div class="form-group mb-0

Blazor client WASM form validation in component not working

这一生的挚爱 提交于 2020-12-15 05:23:27
问题 Im having trouble getting from validation to work properly in a Blazor WASM client application. Encapsulating an InputText element to a component for compact layout does no longer perform validation that is executed correctly otherwise. using model like public class Customer { [Required] [StringLength(100) public string customerName {get; set;} = ""; } in a form of <EditForm Model=@customer> <DataAnnotationsValidator /> <ValidationSummary /> <div class="form-row"> <div class="form-group mb-0

Blazor - How to set value from childcontent property

蓝咒 提交于 2020-12-15 05:14:07
问题 How to set value from childcontent property index.razor <ButtonName>Submit</ButtonName> ButtonName.razor <input type="radio" value=@childContent> <label> @childContent </label> 回答1: You should define a parameter property named ChildContent in ButtonName.razor, like this: [Parameter] public RenderFragment ChildContent { get; set; } And use it like this: <input type="radio" value=@ChildContent> <label> @ChildContent </label> Note that ChildContent contains initial capital letter C 来源: https:/

Component which apply default parameters to other component

萝らか妹 提交于 2020-12-13 04:35:14
问题 I am using Blazorise, which provide multiple base components such as <Button> , with multiple parameters. I would like to create a simple component which would render a <Button> with one or two parameters hard-coded (such as Color="Colors.Primary") and then pass the rest of the parameters onto the <Button> . This is what I would like to be able to write: <PrimaryButton Outline>Text</Button> I would like to achieve this without having to manually set all parameters available from <Button> in

Component which apply default parameters to other component

旧城冷巷雨未停 提交于 2020-12-13 04:35:06
问题 I am using Blazorise, which provide multiple base components such as <Button> , with multiple parameters. I would like to create a simple component which would render a <Button> with one or two parameters hard-coded (such as Color="Colors.Primary") and then pass the rest of the parameters onto the <Button> . This is what I would like to be able to write: <PrimaryButton Outline>Text</Button> I would like to achieve this without having to manually set all parameters available from <Button> in

Blazor Startup Error: System.Threading.SynchronizationLockException: Cannot wait on monitors on this runtime

邮差的信 提交于 2020-12-13 04:09:35
问题 I am trying to call an api during the blazor(client side) startup to load language translations into the ILocalizer. At the point I try and get the .Result from the get request blazor throws the error in the title. This can replicated by calling this method in the program.cs private static void CalApi() { try { HttpClient httpClient = new HttpClient(); httpClient.BaseAddress = new Uri(@"https://dummy.restapiexample.com/api/v1/employees"); string path = "ididcontent.json"; string response =

Blazor Startup Error: System.Threading.SynchronizationLockException: Cannot wait on monitors on this runtime

心不动则不痛 提交于 2020-12-13 04:08:18
问题 I am trying to call an api during the blazor(client side) startup to load language translations into the ILocalizer. At the point I try and get the .Result from the get request blazor throws the error in the title. This can replicated by calling this method in the program.cs private static void CalApi() { try { HttpClient httpClient = new HttpClient(); httpClient.BaseAddress = new Uri(@"https://dummy.restapiexample.com/api/v1/employees"); string path = "ididcontent.json"; string response =

Blazor Startup Error: System.Threading.SynchronizationLockException: Cannot wait on monitors on this runtime

时光总嘲笑我的痴心妄想 提交于 2020-12-13 04:08:16
问题 I am trying to call an api during the blazor(client side) startup to load language translations into the ILocalizer. At the point I try and get the .Result from the get request blazor throws the error in the title. This can replicated by calling this method in the program.cs private static void CalApi() { try { HttpClient httpClient = new HttpClient(); httpClient.BaseAddress = new Uri(@"https://dummy.restapiexample.com/api/v1/employees"); string path = "ididcontent.json"; string response =

Include a Blazor Webassembly project into an existing ASP.NET Core project

泪湿孤枕 提交于 2020-12-13 03:33:21
问题 When creating a new Blazor Webassembly project, there is a checkbox ASP.NET Core hosted where if selected will create three projects at once, a blazor webassembly project, an ASP.NET Core project, and a shared library project. When the ASP.NET Core project is run in Visual Studio, we can debug the blazor project as well as the ASP.NET Core project (put breakpoint, step, etc.). When the ASP.NET Core project is published, the blazor project is also included in the wwwroot folder. I'm not