blazor-server-side

What Is The Correct Way of Closing / Disconnecting An ASP.NET Core signalR Client Connection?

≯℡__Kan透↙ 提交于 2021-02-11 13:12:06
问题 I am a new user struggling to close a secondary signalR client gracefully from an ASP.NET Core Blazor Server Page. I am setting up a secondary signalR client connection on first render of a Blazor Server Page. I am trying to close this secondary signalR client connection when the Page is closed via the browser tab. At the time of writing DisposeAsync does not seem to be triggered when the page is closed via the browser tab. However, the Dispose method IS triggered. Furthermore in Safari 13.0

How to generate dynamically blazor's @bind-Value?

北战南征 提交于 2021-02-11 08:07:33
问题 I'm playing with Blazor and I'd like to create a dynamically generated form, which is part of a grid. The entity type of the data is passed to the grid and this is the base of the form. The problem I'm facing now is @bind-Value , which is needed to be able to edit the given entity. I use BlazorStrap, and it is a Blazor Server Side project. I have the following code in the razor file: @{ string bind = $"{nameof(_editedItem)}.{propertyInfo.Name}"; } <BSBasicInput InputType="InputType.Text" id="

How to generate dynamically blazor's @bind-Value?

柔情痞子 提交于 2021-02-11 08:05:36
问题 I'm playing with Blazor and I'd like to create a dynamically generated form, which is part of a grid. The entity type of the data is passed to the grid and this is the base of the form. The problem I'm facing now is @bind-Value , which is needed to be able to edit the given entity. I use BlazorStrap, and it is a Blazor Server Side project. I have the following code in the razor file: @{ string bind = $"{nameof(_editedItem)}.{propertyInfo.Name}"; } <BSBasicInput InputType="InputType.Text" id="

How do I detect mobile devices in blazor server side application?

安稳与你 提交于 2021-02-10 18:29:26
问题 I need to detect if the user of my blazor server side application is using a mobile device. Is there any way to find out which device the user is using? I know I can do it with a JSRuntime but is there any way to figure it out with pure C#? 回答1: I did find this article that will read you the width and height of a window in Blazor. Looks like it uses JS Interop. With that, you can determine if a user is using a mobile based on the width of their resolution. Of course, it's not 100% full proof

How do I get the Blazor Client browser selected language? (So I can use the right decimal separator for calculations on that client browser)

冷暖自知 提交于 2021-02-10 06:20:12
问题 I try to show and use the right digit separator depending on the clients browser selected language. I'm using a Blazor Server App. I've tried to use the 'Sytem.Globalization' namespace but this only shows the settings of the Server Side browser. Is there a way to get the Client browser language/culure settings? 回答1: You could use javascripts navigator.language property via Interop. https://developer.mozilla.org/en-US/docs/Web/API/NavigatorLanguage/languages public static class JsInterop {

Blazor: binding to a MultiSelectList (ideally with a checkbox)

此生再无相见时 提交于 2021-02-07 06:48:43
问题 Experimenting with Blazor (Server, if that makes any difference), and I'm having difficulty getting binding to a MultiSelectList to work.... Bit of background: I'm dealing with EF Core and have a Many-to-Many relationship, let's say between people and cars. I'm currently loading a page that shows the existing details, and allowing the user to update this page. So in my Service, I load my Person entity from the DB, and this includes the details of all the cars they currently own. I also load

How to add controller (not view) support to a server-side Blazor project

主宰稳场 提交于 2021-02-07 02:36:07
问题 While my server-side Blazor app is running, I want some Javascript code in _Host.cshtml to be able to post data to a controller action. Of course, this happens completely outside of the scope of, and is unrelated to, the Blazor app itself. I thought this would be a matter of adding calls to services.AddControllers() and endpoints.MapControllers() at the appropriate places in Startup.cs . However, after doing this, and implementing the controller action, I made the following observations:

How to Localize validation message (DataAnnotationsValidator) in blazor server side

北战南征 提交于 2021-02-06 10:13:10
问题 I am using blazor 3.1 in latest version of VS 2019. So far, I am able to localize page labels (title, table fields etc.). On the ListEmployee.razor page, I am able to localize table heading etc. On the AddEmplyeeValidation.razor page, I am able to localize form labels but I have a problem localizing the validation messages. For validation message for the Employee.cs file, validation message are defined in the Resources/Data folder in files Data.Employee.resx and Data.Employee.ar.resx but this

How to Localize validation message (DataAnnotationsValidator) in blazor server side

依然范特西╮ 提交于 2021-02-06 10:12:21
问题 I am using blazor 3.1 in latest version of VS 2019. So far, I am able to localize page labels (title, table fields etc.). On the ListEmployee.razor page, I am able to localize table heading etc. On the AddEmplyeeValidation.razor page, I am able to localize form labels but I have a problem localizing the validation messages. For validation message for the Employee.cs file, validation message are defined in the Resources/Data folder in files Data.Employee.resx and Data.Employee.ar.resx but this

Blazor page elements other than Body

此生再无相见时 提交于 2021-02-04 06:28:46
问题 I have a Blazor server-side app, trying to understand the structure. Inside the MainLayout.razor page, I see the tag @Body, and this is where each page's content is rendered. I am wondering, is it possible to add additional render element to the mainLayout page? For example, a @Header section. And I would prefer to define this section inside each individual page as well. In other words, for each page, besides the main content, it also needs to define Header, Footer, or whatever render element