blazor

BL0005 - external parameter usage - why is a warning for that?

萝らか妹 提交于 2020-01-04 04:46:05
问题 BL0005:Component parameter should not be set outside of its component. I have a component inside a component. When my outer component state changes, I want to update inner component's state. The outside component is an autocomplete implementation, the state that changes is input text, the inner component is autocomplete items list, its highlighted part to be exact. So I change the inner component state via its parameter. And I get this warning. Why? BTW, the code works exactly as I expected

How to detect key press without using an input tag in Blazor

可紊 提交于 2020-01-04 01:46:27
问题 I want to be able to capture keyboard input without using an HTML INPUT tag in Blazor. Once the key is pressed i will display a graphic to represent the letter pressed. Something like this @page "/counter" @using Microsoft.AspNetCore.Components.Web <div @onkeypress="e => KeyPress(e)"> Press any letter key </div> @code { private void KeyPress(KeyboardEventArgs e) { var letter = e.Key; } } The KeyPress method does not appear to be called when I set a breakpoint on it. Any help much appreciated.

How to add ViewModel localization to Blazor?

谁说我不能喝 提交于 2020-01-03 05:18:49
问题 We all know the lack of ViewModel localization in Blazor Today i tried many ways, and i came up with a good method to be followed to apply localization 回答1: You can create an abstract base ViewModel for all properties for example “ProductViewModelBase“ Then makes all of your ViewModelBase Properties as virtual public abstract class ProductViewModelBase { public virtual string ProductCode { get; set; } public virtual string ProductType { get; set; } public virtual string ProductName { get; set

Blazor Windows Authentication on Kestrel works locally only? An anonymous request was received in between authentication handshake requests

大城市里の小女人 提交于 2020-01-03 01:59:07
问题 I created a Blazor application with Windows authentication and hosting with Kestrel/Negotiate following the steps. Create Blazor app with Windows Authentication Create a Blazor application using Visual Studio 2019 (16.4.0). (Windows Authentication, https) Support Windows Authentication using Negotiate and Kerberos Following the steps to make all work when running using Kestrel. Import NuGet package Microsoft.AspNetCore.Authentication.Negotiate Add the following code in ConfigureService() in

Windows Authentication works on IIS but not Kestrel / Microsoft.AspNetCore.Authentication.Negotiate (not in Chrome, sometimes in Edge, always in IE)?

只愿长相守 提交于 2020-01-01 15:11:36
问题 I created a new Blazor (Server-side) application with Windows Authentication and run it using IIS Express. It will display a message of "Hello Domain\User!" from the following razor component ( ...\BlazorApp1\BlazorApp1\Shared\LoginDisplay.razor ) on top right. <AuthorizeView> Hello, @context.User.Identity.Name! </AuthorizeView> If running using Kestrel, the message is not shown. So I tried the following steps to make it work in Kestrel. Import NuGet package Microsoft.AspNetCore

Windows Authentication works on IIS but not Kestrel / Microsoft.AspNetCore.Authentication.Negotiate (not in Chrome, sometimes in Edge, always in IE)?

你离开我真会死。 提交于 2020-01-01 15:09:31
问题 I created a new Blazor (Server-side) application with Windows Authentication and run it using IIS Express. It will display a message of "Hello Domain\User!" from the following razor component ( ...\BlazorApp1\BlazorApp1\Shared\LoginDisplay.razor ) on top right. <AuthorizeView> Hello, @context.User.Identity.Name! </AuthorizeView> If running using Kestrel, the message is not shown. So I tried the following steps to make it work in Kestrel. Import NuGet package Microsoft.AspNetCore

Blazor how to pass arguments to onclick function?

假装没事ソ 提交于 2020-01-01 09:21:54
问题 I'd want to make button onclick function that takes some input. <button onclick="@test(123, 456)">Check</button> @functions { public void test(int a, int b) { Console.WriteLine(a + b); } } But for some reason it throws an error: Argument "1": Cannot convert from void to string Later I'd want to create those buttons in for loop like @for (int i = 0; i < 10; i++) { <button onclick="@test(i, 5 * i)">Check</button> } How can I achieve that? 回答1: Try it with a lambda. You're binding the onclick to

Blazor vs Razor

扶醉桌前 提交于 2020-01-01 01:29:11
问题 With the invention of Blazor, I'm wondering if there are significant efficiencies (both in creation of code and in the actual compilation / execution of code) between these two languages? https://github.com/SteveSanderson/Blazor If anyone has actually implemented it, have you undertaken any performance tests, or have anecdotal (yes sorry, apologies I'm requesting this) feedback on the code-writing process, when compared with plain old Razor? 回答1: The information I am presenting below is

How to use Bootstrap Carousel in Blazor

笑着哭i 提交于 2019-12-31 01:19:05
问题 newbie in Blazor. Need to try out how to use BS carousel in Blazor. I used below code in the Default Blazor app. But it does not work. What I need to do? Thanks I added this line in the Index.html <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.0/jquery.min.js"></script> In the Counter page. I added the following: <div class="container"> <div class="carousel-inner"> <div class="item active"> <img src="la.jpg" alt="Los Angeles" style="width:100%;"> <div class="carousel-caption">

Blazor: A second operation started on this context before a previous operation completed

时间秒杀一切 提交于 2019-12-29 08:23:06
问题 I'm creating a server side Blazor app. The following code is in the Startup.cs . services.AddDbContext<MyContext>(o => o.UseSqlServer(Configuration.GetConnectionString("MyContext")), ServiceLifetime.Transient); services.AddTransient<MyViewModel, MyViewModel>(); And in the ViewModel: public class MyViewModel : INotifyPropertyChanged { public MyViewModel(MyContext referenceContext) { _myContext = myContext; } public async Task<IEnumerable<Dto>> GetList(string s) { return await _myContext.Table1