blazor

How to prevent default navigation for Blazor NavLink component

会有一股神秘感。 提交于 2020-03-24 14:19:56
问题 Since Blazor 3.1 Preview 2 it should be possible to prevent default navigation behaviour for links in Blazor, as also discussed in this answer. However, this code: <NavLink href="" Match="Match" @onclick:preventDefault @onclick="()=>LinkAction()" > Do something </NavLink> gives this error: The component parameter 'onclick' is used two or more times for this component. Parameters must be unique (case-insensitive) Why is that? 回答1: Although the net result of the HTML <A> tag and the Blazor

How to prevent default navigation for Blazor NavLink component

橙三吉。 提交于 2020-03-24 14:18:19
问题 Since Blazor 3.1 Preview 2 it should be possible to prevent default navigation behaviour for links in Blazor, as also discussed in this answer. However, this code: <NavLink href="" Match="Match" @onclick:preventDefault @onclick="()=>LinkAction()" > Do something </NavLink> gives this error: The component parameter 'onclick' is used two or more times for this component. Parameters must be unique (case-insensitive) Why is that? 回答1: Although the net result of the HTML <A> tag and the Blazor

How to format the date using local culture using the blazor <InputDate /> tag

橙三吉。 提交于 2020-03-23 12:38:09
问题 I am using the tag in my Blazor app. But how can i format the date using my own culture ? <InputDate class="form-control" @bind-Value="@ValidDate" @bind-Value:culture="nl-BE" @bind-Value:format="dd/MM/yyyy" /> regards Dieter 回答1: The answer is @bind-Value:format , like so @page "/" <EditForm Model="@CurrentPerson"> <InputDate @bind-Value="@CurrentPerson.DateOfBirth" @bind-Value:format="dd/MM/yyyy"/> </EditForm> @code { Person CurrentPerson = new Person(); public class Person { public DateTime

Blazor form submit needs two clicks to refresh view

隐身守侯 提交于 2020-03-23 07:27:12
问题 I have the following Blazor component I'm testing an API call to get weather data. The submit button needs to be clicked twice for some reason in order for the table to display the updated object's properties. When the page initializes I get the location from the browser just fine and the weather data is displayed in the table without issue. FetchData.razor @page "/fetchdata" @using BlazingDemo.Client.Models @using AspNetMonsters.Blazor.Geolocation @inject HttpClient Http @inject

通过 Serverless 加速 Blazor WebAssembly

你离开我真会死。 提交于 2020-03-18 18:27:00
3 月,跳不动了?>>> 本文为 Serverless 社区成员撰稿。作者杨舜杰,系统架构研发工程师,开源爱好者,.NET 开源项目 shriek-fx 作者 Blazor ❤ Serverless 我正在开发 Ant Design 的 Blazor 版本,预览页面部署在 Github Pages 上,但是加载速度很不理想,往往需要 1 分钟多钟才完成。 项目地址: https://github.com/ElderJames/ant-design-blazor ,求 Star。 当寻求解决方案时,了解到了 Serverless 可以轻松地部署静态网站到腾讯云的对象存储服务上,经过尝试之后,体验非常好!访问速度就变成了 3 秒钟,心想 Blazor 与 Serverless 结合后,是一定能成功的。 Blazor WebAssembly 简介 Blazor 是 .NET 实现的前端框架,它使一套代码可分别支持服务端 WebSocket 双向绑定或者是运行在 WebAssembly上。Blazor WebAssembly 可以让开发者使用跟熟悉的 Razor 模版同样的开发模型,来开发基于 WebAssembly 的 SPA 应用。目前 Blazor WebAssembly 已经是在 WebAssembly 领域中发展得最完善的 Web 框架。 Serverless 简介

Change class for selected div only

好久不见. 提交于 2020-03-05 04:36:57
问题 I would like it to only change the class for the clicked div . Currently it will change the class for all div s. I have written this as a Blazor component. @for (int i = 0; i < 5; i++) { <div class="@divClass" @onclick="_ => ChangeDivClass()">@i</div> } @code { String divClass; private void ChangeDivClass() { if (divClass == "red") { divClass = String.Empty; } else { divClass = "red"; } } } 回答1: You can use an array instead of one variable. @for (int i = 0; i < divClass.Length; i++) { var

How to disable/hide a button as soon as clicked in Blazor?

生来就可爱ヽ(ⅴ<●) 提交于 2020-03-03 10:30:02
问题 We are noticing that in our Blazor server-side application, users are able to click a button more than once unintentionally. How can I prevent this using options available in Blazor framework? Anything as simple as changing the text of the button to "processing..." as soon as they click the button will suffice our requirements but I am not sure how to achieve this. Handler for click event takes few seconds to process. Any pointers? 回答1: You likely have one of two problems or both: Latency is

How to disable/hide a button as soon as clicked in Blazor?

◇◆丶佛笑我妖孽 提交于 2020-03-03 10:28:10
问题 We are noticing that in our Blazor server-side application, users are able to click a button more than once unintentionally. How can I prevent this using options available in Blazor framework? Anything as simple as changing the text of the button to "processing..." as soon as they click the button will suffice our requirements but I am not sure how to achieve this. Handler for click event takes few seconds to process. Any pointers? 回答1: You likely have one of two problems or both: Latency is

how to take token from http client with signalr in blazor server app?

半腔热情 提交于 2020-03-03 07:29:23
问题 I using SignalR in my Blazor server app. I added services.AddSignalR() in startup.cs file. Then I can't take token. Because http context is null . Then I removed services.AddSignalR() from startup.cs file. it is normal working. Then i can take token from http client. How to solve it? Thank you. Startup.cs file: services .AddAuthentication(options => { options.DefaultScheme = "Cookies"; options.DefaultChallengeScheme = "oidc"; }) .AddCookie("Cookies") .AddOpenIdConnect("oidc", options => {

how to take token from http client with signalr in blazor server app?

被刻印的时光 ゝ 提交于 2020-03-03 07:29:06
问题 I using SignalR in my Blazor server app. I added services.AddSignalR() in startup.cs file. Then I can't take token. Because http context is null . Then I removed services.AddSignalR() from startup.cs file. it is normal working. Then i can take token from http client. How to solve it? Thank you. Startup.cs file: services .AddAuthentication(options => { options.DefaultScheme = "Cookies"; options.DefaultChallengeScheme = "oidc"; }) .AddCookie("Cookies") .AddOpenIdConnect("oidc", options => {