This is the code I am working on, this is within a list
@foreach(var item in list){
<NavLink href=link>@item.Name</NavLink>
}
I would like link to be "mylink/item.Id", however I have tried the following with no success:
private string link = "mylink/"
and then href = @(link +item.Id)
.href=@("mylink/+item.Id")
href="mylink/{@item.Id}"
and a few others, but all I have gotten is an error "can't mix markup with c# code", so I am completely lost here, any help?
This is a Razor page, with Blazor
try this :
@foreach(var item in list){
var link = $"mylink/{item.Id}";
<NavLink href=@link >@item.Name</NavLink>
}