blazor

@RenderSection Equivalent in Blazor?

一笑奈何 提交于 2019-12-11 07:34:36
问题 Razor pages have a mechanism where you can reference named sections in your layout, and then specify them in your pages that use that layout. For example, if your Layout (_Layout.cshtml) looks like this: @using... ... <!DOCTYPE html> ... <body> ... @RenderSection("modals", required: false) ... and then in your dashboard page, for example, you'd have: <div> ... </div> ... ... @section modals { <div class="modal-container>...</div> <div class="modal-container>...</div> } that would inject the

How to deserialize a json in .net core 3.0

房东的猫 提交于 2019-12-11 07:28:06
问题 I have been facing some trouble to deserialize a json using .Net Core 3.0 Blazor app. The Framework i am using .Net Core 3.0 Blazor with Visual Studio Preview 2019 { "cols": [ "ID", "LastName", "Firstname", "middlename", "Suffix", "Title" ], "rows": [ [ "90", "Dada", "Mama", "", "", "" ] ] } Expected result: i want to load this json dynamically as a table in the web form using blazor. I don't mind to use any UI framwork for this like devexpress or telerik. id LastNmae Firstname middlename

Cant find MouseEventArgs

心不动则不痛 提交于 2019-12-11 06:38:42
问题 I have been following along with Create and use ASP.NET Core Razor components I am having an issue with this section <div class="panel panel-default"> <div class="panel-heading">@Title</div> <div class="panel-body">@ChildContent</div> <button class="btn btn-primary" @onclick="OnClick"> Trigger a Parent component method </button> </div> @code { [Parameter] public string Title { get; set; } [Parameter] public RenderFragment ChildContent { get; set; } [Parameter] public EventCallback

Can you use a ViewComponent in a Blazor layout

我只是一个虾纸丫 提交于 2019-12-11 04:53:33
问题 Just trying Blazor for the first time. With the default blazor template, I added a ViewComponent call to the MainLayout.cshtml: @await Component.InvokeAsync("HeaderComponent") Intellisense shows await can only be used in an async method. I tried the same in a Blazor view - same result. I use the component in an MVC app in the layout (i use vc:header-component there). So I'm not sure if this is possible, or just a current Blazor or VS2019 limitation. 回答1: No, you can't use ViewComponent in

Multiple query string parameters in Blazor routing

谁说胖子不能爱 提交于 2019-12-11 04:24:45
问题 I have multiple working examples in my current project of retrieving 1 query parameter from the url however when trying to follow the same convention for multiple url params, I'm receiving the following error in the chrome debugger console: Error: System.InvalidOperationException: 'Router' cannot find any component with a route for '/confirmemail'. my page route is defined as: @page "/confirmemail/{Token}/{UserId}" and the @functions{...} section contains the following properties: [Parameter]

JSInterop.Json.Deserialize is losing milliseconds from DateTime objects

醉酒当歌 提交于 2019-12-11 03:42:57
问题 In my Blazor 0.9.0 project I have a large json string for a list of objects with DateTime property including milliseconds. This is passed to my .cshtml file via Ajax and I call Microsoft.JSInterop.Json.Deserialize on the string. This deserializes well except the DateTime objects lose their milliseconds. For JsonConvert this can be rectified by using JsonSerializerSettings DateParseHandling. How do we do this in Blazor? var json = "{\"timestamp\":\"2019-03-01T12:22:26.102Z\"}"; I expect this

What's the difference between ASP.NET Core Hosted and Server-Side Blazor, really?

一世执手 提交于 2019-12-11 02:22:15
问题 I'm still struggling to understand the difference between ASP.NET Core Hosted and Server-side Blazor. I know same question already exists, but it's not satisfying. In fact, I couldn't find the satisfying answer anywhere - the answers were more or less the same. If hosted option uses server (IIS, Kestrel), then why server-side ? Confusing... It's a shame that official documentation didn't shed the light either... UPDATE The confusion stems from the fact that we have THREE options to create

How to get local data source in server side applications?

独自空忆成欢 提交于 2019-12-11 01:39:50
问题 I am using blazor server side application. In that I need to refer local dataSource. I have used the Http as like default client side sample. @code{ ChartData[] dataSource; protected override async Task OnInitAsync() { dataSource = await Http.GetJsonAsync<ChartData[]>("scripts/aapl.json"); } } But I have been facing the issue like below, Can anyone guide me to fix this? 回答1: Unlike client-side Blazor, server-side Blazor requires you to add HttpClient to the DI Container, and inject it into

Can I use an Autorest client in blazor

拥有回忆 提交于 2019-12-11 01:38:17
问题 I am getting a System.PlatformNotSupportedException from the mono platform when trying to run my blazor app on webassembly. I autogenerated a web api client using Autorest. Everything is compiling fine but when I load the code in the browser I get the error below in the browser console. Using a preview build of VS2017. module.printErr @ MonoPlatform.ts:192 WASM: [System.PlatformNotSupportedException] Operation is not supported on this platform. WASM: at System.Net.WebProxy.CreateDefaultProxy

Blazor two-way bind not detected when is updated from JS

 ̄綄美尐妖づ 提交于 2019-12-11 00:59:56
问题 I have a simple two-way binded component: <input type="text" id="myInput" bind="@MyVar" /> ... @functions { private string MyVar { get; set; } = "foo"; All runs fine when I write text on input box. But, if input value is set from javascript then blazor is no able to detect the changed value. document.getElementById('myInput').value='Random Value'; I tried to raise some events on element like 'key pressed' and so but the private var MyVar has no changes on blazor client side. I would like to