Vlado Pandžić
Vlado Pandžić

Reputation: 5048

Blazor navigate to same URL but different id

I have problem when navigating from

"/vehicle-definitions/1/can-networks/5" to

"/vehicle-definitions/1/can-networks/6"

Basically, what happens is nothing. I would like and excepted behaviour is to load this new page with id 6, load from database, and show new item on page. But it seems, Blazor thinks this is same page (what basically it is). I tried with <a href , and setting lik using <NavLink but without success

Upvotes: 0

Views: 1846

Answers (1)

David Stania
David Stania

Reputation: 148

you have to override the OnParametersSetAsync() methode and reload data from Database.

First change you route like below

/vehicle-definitions/1/can-networks/{id}

Then you set a property with [ParameterAttribute]

[Parameter] 
public string Id{ get; set; }

And now you can override the OnParametersSetAsync methode and reload new data with changed parameter

protected override async Task OnParametersSetAsync()
{
    LoadData(Id);
} 

Upvotes: 3

Related Questions