blazor

Blazor get nested components by Reflection

流过昼夜 提交于 2019-12-10 23:54:10
问题 I'm actually working on form validation in Blazor project (0.8.0). I have created a component called InputValidation. This component receive many parameters to test if a property value is correct according a condition we can set up. @using System.Linq.Expressions; @typeparam TItem @if (!Valid) { <span id="@(Id)_validation" class="form-text text-danger">@Message</span> } @functions { [Parameter] string Id { get; set; } [Parameter] TItem Property { get; set; } [Parameter] Expression<Func<TItem,

Blazor Components in Razor Pages

眉间皱痕 提交于 2019-12-10 17:22:18
问题 We have a basic razor page app. We would like to add Blazor components. We have no problem getting this to work via replicating the steps in the 04/16 Blazor Update video or using the Blazor documentation. However, once we add the Blazor component to a Razor page, all of our asp-page links no longer work. The url changes in the address bar, but we remain on the same page. The startup file is as follows: public void ConfigureServices(IServiceCollection services) { services.Configure

How to use TagHelpers in Blazor?

巧了我就是萌 提交于 2019-12-10 16:39:19
问题 I created a tag helper and wanted to use that in my Blazor sample project. However, when I want to use the tag helper, the compiler complains about that: CS0103 The name 'StartTagHelperWritingScope' does not exist in the current context FirstBlazorApp . What is additionally required to make tag helpers work in Blazor? 回答1: Tag helpers are not supported in Blazor. At least not as of now. 回答2: On A blazor page you would use a blazor component, this is like a TagHelper but it runs client side

How do I get client IP and browser info in Blazor?

二次信任 提交于 2019-12-10 16:28:49
问题 How do I get client information such as IP adress and browser name/version in Blazor server-side? 回答1: Note that this is only referring to server-side Blazor . "There is no a good way to do this at the moment. We will look into how we can provide make this information available to the client." Source: Blazor dev at Github Workaround The client makes an ajax call to the server, which then can pick up the local ip number. Javascript: window.GetIP = function () { var token = $('input[name="_

Redirecting in blazor with parameter

China☆狼群 提交于 2019-12-10 15:56:51
问题 Hello how can you redirect to another page in Blazor with a parameter? @page "/auth" @using Microsoft.AspNetCore.Blazor.Services; @inject AuthService auth @inject IUriHelper urihelper; <input type="text" bind="@Username" /> <button onclick="@AuthAsync">Authenticate</button> @functions{ public string Username { get; set; } public string url = "/home"; public async Task AuthAsync() { var ticket=await this.auth.AuthenticateAsync(Username); urihelper.NavigateTo(url); //i see no overload that

Blazor the type or namespace name 'App' could not be found (are you missing a using directive or an assembly reference?)

ε祈祈猫儿з 提交于 2019-12-10 15:39:06
问题 I have setup the basic application in Blazor in Microsoft Visual Studio Community 2019 Version 16.1.3 and I have tried both of the versions of .NET Core SDK 3.0.100-preview5-011568 and SDK 3.0.100-preview6-012264. Also I have installed the Blazor extension but when I am building without any modification in any files, the build fails with the following error: "The type or namespace "App" could not be found. Any help will be highly appreciated. Thanks. 回答1: To use Blazor you need to have VS2019

Blazor onclick event passing in counter from loop

[亡魂溺海] 提交于 2019-12-10 15:06:52
问题 I'm currently implementing table paging via a home grown solution in Blazor and coming across some difficulty. The troublesome piece of code is below (this is for rendering the paging buttons below a grid): @for (int i = 0; i < vm.TotalPages; i++) { <button id="pg-button-@i" class="btn btn-primary btn-sm" type="button" onclick="@(() => GetTablePage(i))">@i</button> } Notice in the onclick event, I am calling a function and passing in i , the counter for the current interation of the loop. The

Why does page not update after refresh when .cshtml changes

我是研究僧i 提交于 2019-12-10 14:20:34
问题 I am trying out Blazor and i do not understand why when changing a component after refreshing the browser page it does not update ? Shouldn't the client update itself similar to how angular does? It only refreshes when i restart the blazor server. Index.cshtml @page "/" <h1>Hello, world!</h1> If i change lets say the text inside the <h1> to Hello people , i save the project and i refresh the page ( as i am advised in the Blazor tutorial) shouldn't i see Hello people ? 回答1: I guess you are

Blazor Server - static files don't link in non-DEV environments

末鹿安然 提交于 2019-12-10 10:38:48
问题 It seems in a standard Blazor server app, the _content folder items are not being referenced correctly for anything other than the Development environment. As an example, this reference fails in any non-dev environment: from _Host.cshtml: <link href="_content/Blazored.Typeahead/blazored-typeahead.css" rel="stylesheet" /> To Repro, using Blazored-toast lib as an example (but any static file refs seem to have this issue): Create a new Blazor Server project (dotnet new blazorserver) Add all

Can a Blazor app include .NET 4.6.1 Assemblies?

↘锁芯ラ 提交于 2019-12-10 10:19:45
问题 When I create a Blazor app it targets the .NET Standard 2.0 framework. I want to include System.Speech in a Blazor app. Is it possible to target the .NET 4.6.1 framework in Blazor Thanks 回答1: No, you can't. Right now you can target netstandard2.0 on client-side Blazor, and netcoreapp3.0 on the server. Hope this helps... 来源: https://stackoverflow.com/questions/56466486/can-a-blazor-app-include-net-4-6-1-assemblies