Q:

How does the route parameter assign values to properties in Blazor?

0

This code will help you to understand how to route parameter assign values to properties in Blazor

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Blazor doesn’t consider the word casing and it just assigns the value if the name is matched.

@page "/RouteParameter"
@page "/RouteParameter/{name}"

<h1>Welcome to blazor : @Name !!!</h1>


@code {
       [Parameter]
       public string Name { get; set; }

       protected override void OnInitialized()
       {
             Name = Name ?? "David";
       }
}

The router parses the name parameter from the URL and sets the value of the component. For instance, if the URL is /RouteParameter/JonSnow, the Name property will be set to “ JonSnow “.

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now