blazor

Correct way to mutate a component property in blazor

眉间皱痕 提交于 2020-01-23 02:43:11
问题 I have two components, Child.razor and Parent.razor . The Child.razor HTML: <input type="text" value="@Text" /> The Child.razor C#: [Parameter] public string Text { get; set; } And the Parent.razor HTML: <Child @ref="child_1" /> <Child @ref="child_2" /> <Child @ref="child_3" /> Parent.razor C#: Child child_1; Child child_2; Child child_3; void SetText(Child item, string text) { item.Text = text; } I get a warning on the item.Text = text : Warning BL0005: Component parameter 'Text' should not

Is there any hot reload for blazor server-side?

ⅰ亾dé卋堺 提交于 2020-01-22 16:00:28
问题 I have just one, quick question. Is there way to hot reload a blazor app? At least, .razor files? Now I'm hosting my app on local IIS (not IIS express). I was looking through internet, but i didn't found anything helpful. Thank you all for anwsering :) 回答1: Maybe you can try running your application from command prompt: dotnet watch run debug 来源: https://stackoverflow.com/questions/58172922/is-there-any-hot-reload-for-blazor-server-side

Port React app to Blazor app with JavaScript library imported using JavaScript interop

╄→гoц情女王★ 提交于 2020-01-16 09:01:13
问题 I currently have a React app that I'm trying to convert to a Blazor WebAssembly app. The React app has a component that imports a JavaScript library, the sample code for which can be seen here. The imported charting_library code itself isn't accessible without access being granted, but that shouldn't be an issue for answering this question. In my React app, as per the sample code, I have the following code (stripped for brevity): import { widget } from '../../charting_library/charting_library

Blazor route changes in same page

让人想犯罪 __ 提交于 2020-01-15 05:17:48
问题 I'm current setup: .NET core 3 (preview 6) Blazor server side rendering In a Blazor page I have something like the following: @page "/page" @page "/page/{Id}" With: [Parameter] public string Id { get; set; } Now, when navigating from, for example, /page/1 to /page/2 , I can use OnParametersSetAsync to detect these changes. But the problem occurs when navigating from /page/1 to /page . OnParametersSetAsync can detect this change, however the Id parameter will stay as 1 from the previous route.

How do I access the HTML Canvas from Blazor?

扶醉桌前 提交于 2020-01-14 10:31:45
问题 I am trying to do 2D drawing to the HTML Canvas from Blazor. I tried using the Blazor.Extensions.Canvas but it seems to be quite dated and targeted at a prior Blazor Server Side implementation. I tried implementing a simple example and got an exception with... { protected Blazor.Extensions.BECanvasComponent _canvasRef; private Blazor.Extensions.Canvas.Canvas2D.Canvas2DContext _context; // Note I had to provide the full path since it seemed to ignore // my @using statement in most cases

How to update server-side changes on the client side for Blazor Server app?

瘦欲@ 提交于 2020-01-13 07:14:07
问题 My ChangeValues server-side event occurs every 5 seconds but on client-side, I only see the first value of the number variable. See code below @page "/" <button class="btn btn-primary" @onclick="ChangeValues">Click me</button> <b>@number</b> @code { double number; private Random rnd = new Random(); private System.Threading.Timer _timer; void ChangeValues() { number = rnd.NextDouble(); Console.WriteLine(number); } private void DoWork(object state) { ChangeValues(); } protected override async

How to update server-side changes on the client side for Blazor Server app?

痞子三分冷 提交于 2020-01-13 07:13:03
问题 My ChangeValues server-side event occurs every 5 seconds but on client-side, I only see the first value of the number variable. See code below @page "/" <button class="btn btn-primary" @onclick="ChangeValues">Click me</button> <b>@number</b> @code { double number; private Random rnd = new Random(); private System.Threading.Timer _timer; void ChangeValues() { number = rnd.NextDouble(); Console.WriteLine(number); } private void DoWork(object state) { ChangeValues(); } protected override async

How does the Blazor WeatherForecast sample work?

↘锁芯ラ 提交于 2020-01-13 04:42:10
问题 The Hello World project template for Blazor includes a Weather Foreacast example (in addition to the Counter increment example). I played around with this to see whats going on behind the scenes. I cant seem to figure it out. Basically, if i comment out the line of code that fetched the weather .json data, then i see "Loading..." indefinitely. Makes sense thus far. But when i run it in its original state, i see "Loading..." then quickly followed by the rendering of the data grid. My confusion

How can one generate and save a file client side using Blazor?

风流意气都作罢 提交于 2020-01-12 01:45:15
问题 I want to have a SPA that's doing all the work client side and even generating some graphs/visuals. I'd like to be able to have the user click buttons and save the visuals, tables, and other things from the page (that are both seen and not seen, so right click save or copy/paste is not always an option). How do I call a function from the webassembly/blazor library, get it's results and save it as a file on the client side? the idea is something like this...? cshtml <input type="file" onchange

Blazor and Identity

非 Y 不嫁゛ 提交于 2020-01-11 13:53:29
问题 I have a project in .net core 3.0 with 3 parts : api, shared and a blazor app. I added few models in shared project and a user model : [Table("user")] public class User : IdentityUser<Guid> { [Required(ErrorMessage = "Firstname is required")] [StringLength(32, ErrorMessage = "Firstname must be 32 charaters maximum")] [Column("firstname")] public string Firstname { get; set; } [Required(ErrorMessage = "Lastname is required")] [StringLength(32, ErrorMessage = "Lastname must be 32 charaters