blazor

Growing TextArea in Blazor

泪湿孤枕 提交于 2020-05-31 02:43:42
问题 I need a text area that grows as the number of lines increases. As soon as lines are deleted, the TextArea should shrink again. In the best case with a maximum height. How it works with Javascript I could already read here: textarea-to-resize-based-on-content-length But in Blazor I have unfortunately, as far as I know, no "scrollHeight" available for the TextArea. (My problem relates to the Blazor framework, which allows browser frontend development using C# (+HTML/CSS) and not a desktop UI

Blazor WebAssembly: How to get UI to update during long running, non-async process

半腔热情 提交于 2020-05-30 11:25:49
问题 I have some complex calculations that take a while to do. (Yes, I know, client-side may not sound like the ideal place to do them, but there are good reasons for it.) I would like the page to update with results as the calculations progress. I can get the UI to re-render as the calculations progress, but not update the results correctly. Note that the calculations are not inherently async and wrapping them in Task.Run does not seem to help. Here is a simplified version of the code that

Blazor WebAssembly: How to get UI to update during long running, non-async process

别来无恙 提交于 2020-05-30 11:24:43
问题 I have some complex calculations that take a while to do. (Yes, I know, client-side may not sound like the ideal place to do them, but there are good reasons for it.) I would like the page to update with results as the calculations progress. I can get the UI to re-render as the calculations progress, but not update the results correctly. Note that the calculations are not inherently async and wrapping them in Task.Run does not seem to help. Here is a simplified version of the code that

Blazor WebAssembly: How to get UI to update during long running, non-async process

╄→гoц情女王★ 提交于 2020-05-30 11:21:00
问题 I have some complex calculations that take a while to do. (Yes, I know, client-side may not sound like the ideal place to do them, but there are good reasons for it.) I would like the page to update with results as the calculations progress. I can get the UI to re-render as the calculations progress, but not update the results correctly. Note that the calculations are not inherently async and wrapping them in Task.Run does not seem to help. Here is a simplified version of the code that

Blazor WebAssembly: How to get UI to update during long running, non-async process

£可爱£侵袭症+ 提交于 2020-05-30 11:20:32
问题 I have some complex calculations that take a while to do. (Yes, I know, client-side may not sound like the ideal place to do them, but there are good reasons for it.) I would like the page to update with results as the calculations progress. I can get the UI to re-render as the calculations progress, but not update the results correctly. Note that the calculations are not inherently async and wrapping them in Task.Run does not seem to help. Here is a simplified version of the code that

How to change classes of a div element using Blazor

北城以北 提交于 2020-05-29 12:52:11
问题 I have a typical div element in a cshtml page in the form: <div id="loginErrors" class="alert alert-danger hide-errors">@(ErrorMessage)</div> pre Blazor, I'd typically use jQuery to add or remove the hide-errors class from the div. However, Blazor is trying to remove the need for JavaScript and I'm trying to use as little JSInterop as possible. Is there a way in Blazor to do this? so in Blazor I could do: @if (!string.IsNullOrEmpty(ErrorMessage)) { <div id="loginErrors" class="alert alert

Change visibility of nav item in blazor menu

点点圈 提交于 2020-05-29 10:17:18
问题 I'm using Blazor with .NET Core 3.0. I want to show a login in my menu, when the user isn't logged in yet. When he is logged in, then the login nav item should be hidden. How can I do this? EDIT: I changed the OnInitializedAsync method by using async Task, but this is not the problem. For the first load, it works correctly. But then i go to the login page, log me in and Navigate to the home page via NavigationManager, the menu will not be "refreshed". How can I solve this? Following code is

When I should call StateHasChanged and when Blazor automatically intercepts that something is changed?

≡放荡痞女 提交于 2020-05-29 06:47:47
问题 I am having a hard time understanding when I should call StateHasChanged() and when Blazor intercepts that something is changed so it must be re-rendered. I've created a sample project with a button and a custom component called AddItem. This component contains a div with a red border and a button. What I expected: I want that the AddItem's div will show up when the user clicks on the button contained inside the Index page. Then I want to hides it when the user clicks on AddItem's button.

What's the difference between RenderMode.Server and RenderMode.ServerPrerendered in blazor?

浪子不回头ぞ 提交于 2020-05-29 03:32:47
问题 What's the difference between @(await Html.RenderComponentAsync<Todo>(RenderMode.ServerPrerendered)) and @(await Html.RenderComponentAsync<Todo>(RenderMode.Server)) I was looking into the documentation but couldn't really find something that explains the difference. and also don't really understand the code comments over the enum stating: // Summary: // Renders a marker for a Blazor server-side application. This doesn't include any // output from the component. When the user-agent starts, it

What's the difference between RenderMode.Server and RenderMode.ServerPrerendered in blazor?

白昼怎懂夜的黑 提交于 2020-05-29 03:29:10
问题 What's the difference between @(await Html.RenderComponentAsync<Todo>(RenderMode.ServerPrerendered)) and @(await Html.RenderComponentAsync<Todo>(RenderMode.Server)) I was looking into the documentation but couldn't really find something that explains the difference. and also don't really understand the code comments over the enum stating: // Summary: // Renders a marker for a Blazor server-side application. This doesn't include any // output from the component. When the user-agent starts, it