Live Chat Icon For mobile
Live Chat Icon

How do I pass DateTime value as the route in Blazor?

Platform: Blazor| Category : Routing, Event handling

Blazor provides support for passing the route parameter as DateTime format. This needs to be mentioned while defining the route parameter in the route as @page “/route/{parameter:datetime}” at the top of the .razor component file..

Refer to the following code sample.


@page "/"

<button @onclick="CurrentTime">Current Time</button>

@code {
    public void CurrentTime()
        NavManager.NavigateTo("/time/" + DateTime.Now);


@page "/time/{param:datetime}"

@code {
    public DateTime Param { get; set; }

Share with

Related FAQs

Couldn't find the FAQs you're looking for?

Please submit your question and answer.