uncle_scrooge
uncle_scrooge

Reputation: 429

index.html button navigation to razor page

I have an application where we have a button in index.html. So just wanted to navigate from index.html to another razor page which is in PAGES folder called

dashboard.razor 

I am newbie to blazor applications,please help.

Upvotes: 0

Views: 589

Answers (2)

Arani
Arani

Reputation: 1243

First, you have to assign a path for the dashboard.razor by the @page directive on the above of the component. For example:

@page "/dashboard"  

Now you can access to dashboard.razor from everywhere by /dashboard. For example, for the Index.html button, you can do it such as below:

<button onclick="location.href = 'www.yoursite.com/dashboard';" id="myButton" class="float-left submit-button" >Dashboard</button>

Upvotes: 0

Lex
Lex

Reputation: 7194

Use NavigationManager.

@inject NavigationManager NavigationManager;
@code {
    private void MyButtonClick()
    {
        this.NavigationManager.NavigateTo("/dashboard");
    }
}

Upvotes: 1

Related Questions