Paula1999
Paula1999

Reputation: 27

Setting a class property in a shared component in blazor

I have a navbar which is a shared component in Blazor ServerSide. I want to set the address in the href to that I can pass the users ID. I have tried this:

<NavLink class="nav-link" href="/student/registerguest/@StudentId">
                <span class="oi oi-plus" aria-hidden="true"></span> Register Guest
            </NavLink>

And several other variations but I am getting an error that says Component attributes do not support complex content (mixed C# and markup). Is there anyway the @StudentId can be put in here?

Upvotes: 1

Views: 985

Answers (1)

Mark3308
Mark3308

Reputation: 1343

Have you tried using string interpolation for example:

href=@($"/student/registerguest/{student.StudentId}")

Upvotes: 3

Related Questions