blazor

Different method calls in Blazor

此生再无相见时 提交于 2021-01-29 22:22:19
问题 I am experimenting with Blazor for some time now and I am trying to find an explanation about the difference between <input type="button" onclick="@methodCall()">Something</button> and <input type="button" @onclick="() => methodCall()">Something</button> Why is @ expected before onclick vs @ being part of value? 回答1: When you place the "@" before the "onclick", you create a compiler directive. This constructs is going to be enforced in the future, if it is not yet enforced. It instructs the

Different method calls in Blazor

孤街浪徒 提交于 2021-01-29 21:57:09
问题 I am experimenting with Blazor for some time now and I am trying to find an explanation about the difference between <input type="button" onclick="@methodCall()">Something</button> and <input type="button" @onclick="() => methodCall()">Something</button> Why is @ expected before onclick vs @ being part of value? 回答1: When you place the "@" before the "onclick", you create a compiler directive. This constructs is going to be enforced in the future, if it is not yet enforced. It instructs the

Different method calls in Blazor

隐身守侯 提交于 2021-01-29 20:07:40
问题 I am experimenting with Blazor for some time now and I am trying to find an explanation about the difference between <input type="button" onclick="@methodCall()">Something</button> and <input type="button" @onclick="() => methodCall()">Something</button> Why is @ expected before onclick vs @ being part of value? 回答1: When you place the "@" before the "onclick", you create a compiler directive. This constructs is going to be enforced in the future, if it is not yet enforced. It instructs the

basic component layout inheritance blazor

﹥>﹥吖頭↗ 提交于 2021-01-29 19:47:40
问题 Let's say most of my components have a header. I want to create a base component that has the header variable and make all the other components inherit from that component and set the header. So I have BaseComponent @inherits LayoutComponentBase; <h1>@header</h1> @Body @code { protected string header; } Component @inherits BaseComponent; "internal component text" @code { protected override void OnInitialized() { base.header = "Setting header for the parent" } } This compiles and shows up with

How to find position to insert draggable item at when inserting in a new block

て烟熏妆下的殇ゞ 提交于 2021-01-29 18:51:11
问题 I am trying to create a page where I have a list of items to the left and a dashboard on the right. I want to be able to drag an item from the right and drop it in the dashboard view. Using Blazor, how do I fint the position to insert at? From the mouse event I can find screen and Client X and Y, but I need the local position within my dashboard. Can I get the position of the dashboard and manually do the math? Is there any helper functions I dont know about? Example of what I am trying to

Blazor WebAssembly with index file configuration logic causing AmbiguousMatchException

点点圈 提交于 2021-01-29 18:36:40
问题 I am creating a Blazor WASM and I need to include logic within the index.html file to load different css/js files and apply various css styles to body tag based on some conditions. However since the root file is static (www/index.html) and the app tag is nested inside the body tag this is not possible. So I followed this link and created an Index.cshtml file (based on the static index file) in the server project and changed the endpoint in the Startup of the server project to

Blazor MatAutocompletelist throwing System.ArgumentNullException

寵の児 提交于 2021-01-29 17:32:55
问题 I'm building hotel service web application and I'm want to use MatBlazor component called MatAutocompleteList for choosing clients for reservations I've encountered an issue when Client is selected like on the screen And I remove this value leaving it blank and press enter application throws an exception: System.ArgumentNullException: Value cannot be null. (Parameter 'model') at Microsoft.AspNetCore.Components.Forms.FieldIdentifier..ctor(Object model, String fieldName) at Microsoft.AspNetCore

Different method calls in Blazor

我怕爱的太早我们不能终老 提交于 2021-01-29 15:40:22
问题 I am experimenting with Blazor for some time now and I am trying to find an explanation about the difference between <input type="button" onclick="@methodCall()">Something</button> and <input type="button" @onclick="() => methodCall()">Something</button> Why is @ expected before onclick vs @ being part of value? 回答1: When you place the "@" before the "onclick", you create a compiler directive. This constructs is going to be enforced in the future, if it is not yet enforced. It instructs the

Service Lifetimes in Blazor and Navigation

非 Y 不嫁゛ 提交于 2021-01-29 12:05:48
问题 Asumme this setup: Page1: - Component A - Component B Page2: - Component C - Component D Service: MyService I want Component A und B to get the same instance of MyService. Component C and D should get a fresh (and the same) instance of MyService. When I register MyService as transient each Component gets a fresh instance. When I register as singleton / scoped all components share the same instance. Components are part of library and thus I am looking for solution that requries no or very

Owl Carousel not working with ASP.NET Blazor

白昼怎懂夜的黑 提交于 2021-01-29 10:13:39
问题 I have been trying to make this owl carousel work. I am not getting any error but the carousel if not loading. I tried the solution I found on StackOverflow for Bootstrap carousel but it did not work for me. I also tried to use pure CSS carousel but it will be static kind of thing and I want the carousel to work dynamically. Index.razor @page "/" @using TBS.Data; @inject IJSRuntime JsRuntime; @*@inject IComponentContext context;*@ @inject NavigationManager UriHelper; @inject MediaService