Intro - Server side Flashcards
(21 cards)
How to inject a something in a razor page?
Via [Inject] annotation.
How to make more than one project to run in the solution?
By multiple startup projects in the visual studio IDE.
What are the different ways to bind data in Blazor?
One way (read only) and two way (read/write).
What are the default input components in blazor?
InputText, InputTextArea, InputNumber, InputSelect, InputDate and InputCheckbox.
What is a common way to create forms in blazor?
By creating an EditForm with a relation with the model. Then handle input with two-way binds with events to handle valid and invalid inputs.
What’s navigation manager? How to add to the form?
It’s a class that can redirect the user to another pager. Can be added to the form by just adding the [Inject] NavigationManager class.
How does validation in blazor works?
it’s similar to ASP.NET. Works via data annotations.
How to add validation to the shared lib where the model is defined?
By adding a nuget package system.componentmodel.annotations to the shared lib.
How to add data validation to the blazor form?
By adding the element to the form. Also validationsummary to see validation errors. Also specific validations messages can be added to the input fields itself.
Can razor components be nested?
Yes. It’s normal and expected.
What happens to pages when it is composed by components?
It gets smaller and easy to use.
On which folder the components are stored?
In the components folder.
Where to declare new common namespaces in the blazor project?
In the _Imports.razor file.
What are the methods the components can overwrite?
OnInitialized, OnParametersSet and OnAfterRender. All these methods have their async extensions.
Can we have a component folder in a different folder like a shared library?
Yes. It’s quite common. There is no need to have the folder inside the UI project.
When Blazor is no capable of noticing changes to the DOM, how to force it?
Calling StateHasChanged() method.
How a component call tell the page or other component that data was added?
By creating an event that other components or the page can subscribe to.
Where blazor run interoped javascript libs?
Always in the browser… even in server side blazor.
What are the variants of the Blazor-javascript interop?
1 - .NET can call JavaScript;
2 - JavaScript call into .NET;
3 - The two items above can be wrapped into a library.
How to inject javascript in the razor component? Is it included in blazor by default?
Yes, included by default.
[Inject]
public IJSRuntime JsRuntime {get; set;}
What are the downsides of importing a javascript lib into blazor?
It’s necessary to add to add css and javascript in the host.css.