blazor

How to make an EditForm Input that binds using oninput rather than onchange

两盒软妹~` 提交于 2019-12-06 10:46:29
Suppose I want to use an EditForm, but I want the value binding to trigger every time the user types into the control instead of just on blur. Suppose, for the sake of an example, that I want an InputNumber that does this? I've tried using different means that are floating around such as bind-Value:event="oninput" with no success. I was finally able to get more or less what I wanted by copying the AspNetCore source code for InputNumber and overriding / rewriting a few things. Here is my InputNumber which accomplishes what I'm hoping for: public class MyInputNumber: InputNumber<int> { protected

How to Separate Code From UI In Blazor.Net

我怕爱的太早我们不能终老 提交于 2019-12-06 05:48:37
Reference to this VisualStudioMagazine article, I am trying to have code in a separate file instead of razor view. I tried: @page "/Item" @using WebApplication1.Shared @using WebApplication1.Client.Services; @inject HttpClient Http @inherits ItemComponent @if (ItemList != null) { <table class="table"> <thead> <tr> <th>ID</th> <th>Name</th> <th>Category</th> <th>Metal</th> <th>Price</th> <th>Quantity</th> </tr> </thead> <tbody> @foreach (var item in ItemList) { <tr> <td>@item.ID</td> <td>@item.Name</td> <td>@item.Category</td> <td>@item.Metal</td> <td>@item.Price</td> <td>@item.Quantity</td> <

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

自古美人都是妖i 提交于 2019-12-06 04:38:46
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 necessary Blazored / Toast elements, including code to demo a toast message Test that toast is working

Auto inject javascript in blazor application

▼魔方 西西 提交于 2019-12-06 04:10:26
问题 I'm developing a Blazor extension library. One thing in this library would be the reuse of the javascript alert() method. I know how to do this, this involves adding this in a .cshtml page: <script> Blazor.registerFunction('Alert', (message) => { alert(message); }); </script> and this in my code: public void Alert(string message) { RegisteredFunction.Invoke<object>("Alert", message); } I would like the javascript part somehow to be auto injected in the html if you use my package (or maybe

How can I deploy a Blazor server-hosted application from Visual Studio 2019

天涯浪子 提交于 2019-12-05 19:37:26
I am using VS2019 Preview. I have created a "server-hosted" Blazor application using the latest Blazor extension (16.0.19227). This is the variant that contains 3 separate projects... MyApp.Client MyApp.Server MyApp.Shared I can debug this by making MyApp. Server the active project and all works fine but I'm struggling to publish/deploy this to Azure. I have tried the following... Right-click on MyApp.Server in Solution-Explorer Choose "Publish" Go through the wizard to create a new publish profile Change the deployment mode to "self-contained" Hit publish At this point I get an error during

Blazor Textfield Oninput User Typing Delay

眉间皱痕 提交于 2019-12-05 08:14:17
How can I add a delay to an event (OnInput) in Blazor ? For example, if a user is typing in the text field and you want to wait until the user has finished typing. Blazor.Templates::3.0.0-preview8.19405.7 Code: @page "/" <input type="text" @bind="Data" @oninput="OnInputHandler"/> <p>@Data</p> @code { public string Data { get; set; } public void OnInputHandler(UIChangeEventArgs e) { Data = e.Value.ToString(); } } Solution: There is no single solution to your question. The following code is just one approach. Take a look and adapt it to your requirements. The code resets a timer on each keyup ,

Adding Server-Side Blazor to an existing MVC Core app

ⅰ亾dé卋堺 提交于 2019-12-05 07:48:20
I have a fully operative Blazor server-side project and a .NET Core 3 MVC project, both in the same solution. I'm now trying to use the components from the Blazor project in my MVC project. I've managed to get the components to render on an MVC page, but button clicks on the Blazor component don't trigger the onclick events for the components, instead I just get navigated to https://localhost:44341/ ? I'm unclear as to exactly what changes I need to make in the MVC solution to get this working? The official documentation talks about using components in and MVC project and it's mentioned in

Blazor client side debugging fails

两盒软妹~` 提交于 2019-12-05 07:07:20
When trying to debug a Blazor client side app I keep getting the error Debugging connection was closed. Reason: WebSocket disconnected I open Chrome with "%programfiles(x86)%\Google\Chrome\Application\chrome.exe" --remote-debugging-port=9222 https://localhost:50868/ and do not have any extensions installed in Chrome. I followed the instructions https://docs.microsoft.com/en-us/aspnet/core/blazor/debug?view=aspnetcore-3.0 but no luck. Have you guys ever faced this situation? Any idea on where I should be looking at? I ran into the same thing. Since your URL contains https://localhost , the

Properly publishing/deploying a blazor project to github pages

牧云@^-^@ 提交于 2019-12-05 03:30:59
问题 I'll start this by saying I'm definitely working a bit above my paygrade here. I'll be doing my best to describe this problem and make it easiest to answer. I've made a Blazor project in Visual Studio and this is connected to the GitHub repository here in the gh-pages branch. After reading Blazor's hosting and deploying guide here, I published the project in Visual Studio and copied the files in the /bin/Release/netstandard2.0/publish/ChargeLearning/dist folder to the root of the repository

Blazor: Implementing 404 not found page

血红的双手。 提交于 2019-12-05 01:34:26
问题 I'd like to implement a page internal to my application that appears when the blazor router is unable to find a matching route. Currently, all requests are routing to index.html so I'm unable to handle errors through iis as I may normally. If I enter an invalid route, I will be shown a blank page (which is actually index.html ) and receive a console error: 'Router' cannot find any component with a route for '/some/Nonexistent/Route'. It seems like I should be able to handle this since the