Blazor | Please see the new repo | Frontend Framework library
kandi X-RAY | Blazor Summary
kandi X-RAY | Blazor Summary
MOVED: Please see the new repo at
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of Blazor
Blazor Key Features
Blazor Examples and Code Snippets
Community Discussions
Trending Discussions on Blazor
QUESTION
I build a notification system which shows a bootstrap alert div in a NotificationHandler
blazor component. This works fine but the notifications stay there. I'd like to make these notifications disappear after x seconds. How can I do this while not blocking UI and making sure it is executed on the blazor render thread.
See example code below:
...ANSWER
Answered 2021-Jun-15 at 14:34await InvokeAsync(async () => // note the 'async'
{
_notifications.Add(notification);
StateHasChanged();
// TODO: remove notification the _notifications after x seconds
await Task.Delay(2_000); // x = 2
_notifications.Remove(notification);
StateHasChanged();
});
QUESTION
I have the requirement to be able to present a document on a website, in the browser. (not download it) and well the way I know to tackle this (without paying to 3rd parties software) is an Iframe, but that sounds like a really old practice. I'm currently developing an application on Blazor and .net5 and sounds really wrong to put an iFrame in there, can you guys provide me input for better practices or just your thoughts?
Thanks in advance.
Edit: Im trying to use them to present doc, docx, pdf and pngs in a blazor application with .net5
...ANSWER
Answered 2021-Jun-14 at 17:41Honestly, after days of research, I'm trying to talk the team into the idea of creating an API dedicated to Docs, and as part of that effort would migrate documents to AWS S3 or azure blob storage. We will introduce Aspose for rendering and separate the Issue.
Why? because all the solutions I have seen to support doc and Docx in .net5 are really hacky and I can see lacks in terms of security. And I would not recommend anyone to try to do the approach I was looking to do at the begging of this question.
I leave here what experience cause this research was pain and I hope this question can still help someone.
QUESTION
In my Blazor serverside application, I am trying to inject JSRuntime according to this documentation: https://blazor-university.com/javascript-interop/calling-javascript-from-dotnet/
To add JSRuntime to my project, I've added the following line in the ConfigureServices function of the Startup.cs file:
...ANSWER
Answered 2021-Jun-14 at 17:42You need to include the using
statement, either in the component.razor file, or in _Imports.razor (preferred if you are going to be using JSInterop
often):
QUESTION
I am trying to publish a .NETCORE blazor server side project on a QA server Everything work good in my local machine but when i publish my project, when i click the buton i need, it give me : Object reference not set to an instance of an object. exeption.
when i debug and log step by step i see that it come from a ligne where i use a dll that i found thereExcelToObjectConvertor, i downloaded it and put it in my root/Ressources folder. Here is how i use it and it work good again in my local machine when i start in visual studio i get my dataToUpdatesList -> OK
...ANSWER
Answered 2021-Jun-11 at 13:53If the workSheetList object is null, I don't think it's a DLL problem - that would throw an Exception for a missing assembly. Is your "produitsTEST.xls" file on your QA server, and at the FilePath you specify? I would check that first.
I would also throw in some error handling in the event that workSheetList does come back as NULL.
QUESTION
I've tried to use this code in my .NET 5 Blazor project, in .razor file:
...ANSWER
Answered 2021-Jun-13 at 06:31You cannot apply a class to a Component. You can use splatting to capture attributes placed on a Component to pass as parameter to one of the components elements.
SomeComponent.razor
QUESTION
I have a select control bound to a selected value. Since I can't use @onChange and @bind at the same time, what's the @bind version of:
...ANSWER
Answered 2021-Jun-09 at 13:46You dont have to use a setter. Just a computed property based on the bind value.
QUESTION
Ok, a rather specific question which requires additional explanation and context.
Context
We are POCing a "try-convert" from a bespoke language to .net core (5 currently) and blazor server. Server because it allows a try-convert scaffolding we can build security concerns round. The details of this are not important. It just explains why we have some constraints which may seem unrealistic under normal circumstances.
I am fully accepting that "no you can't" or even "no you shouldn't" is the likely outcome. We are exploring possibilities.
Question
The concept of a circuit in blazor is a really good fit for the presentation layer. We would like to store information at the scope of the circuit.
The obvious solution is to use a scoped service in the dependency injection container.
E.g. In my Startup.cs I can put
...ANSWER
Answered 2021-Jun-12 at 12:56As far as I understood both your question and the Blazor concepts, the answer to your question is « no ». There is no possibility to retrieve statically the current HTTP context in Blazor. Because you never know if the context is an initial page load or just SignalR communication to update the current page. Here is the manner I save this situation:
Create a cascading parameter that is shared by all razor components
This cascading parameter is a class with many information coming from initial HTTP request, caught in the _Host.cshtml from the httpContextAccessor.HttpContext
This cascading parameter class gets all the methods of my previous static methods.
These methods can use the properties of the cascading parameter: RawUrl, UserAgent, ClientIp, …
This implies hard refactoring work to migrate legacy ASP web sites. But the performances of Blazor are worth it.
QUESTION
I am working on a blazor server side project.
When I try to write integration tests for my repository pattern services I get the error:
System.PlatformNotSupportedException : This platform does not support distributed transactions.
.
Trying to use a second connection and query whether the desired data was really saved triggers the error.
My test code:
...ANSWER
Answered 2021-Jun-12 at 09:14Finally got it running using the following code:
QUESTION
I am working on a blazor server side project.
I wrote a repository pattern class for my queries and had some troubles with the function Task> GetAllModelsAsync()
. I want it to return a task so I can await its result within my partial components class to allow more responsive rendering.
I got it working using the following code:
...ANSWER
Answered 2021-Jun-12 at 08:27This is how I've been using Dapper. Works great:
- Make your Dapper method
async
. - Make the method or event that CALLS your method an
async Task
as well, so you canawait
the Task. - To return a list, do
return (await blah blah blah).ToList();
- Use the
Async
versions of all SQL calls.
Something seems a little off with your foreach loop. Would you mind explaining what you're trying to achieve with it? It seems like your first query should return all the models you need.
Example:
QUESTION
How I can Create a timer component in Blazor and start it from outside of component or other page. My component code is as below:
...ANSWER
Answered 2021-Jun-12 at 05:39You don't actually create a timer component as you post in the question title. What you actually want is to create a service class which you can inject into your components. You can do that in various ways, and provide whatever functionality you want.
Your timer service class may look something like this (Warning you should also implement the IDisposable interface to dispose the timer in order to prevent memory leaks
):
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install Blazor
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page