Reputation: 9073
I am writing this page on a blazor-server application:
@page "/pageurl/{param:int}"
@attribute [AnAttribute(param)]
<div>@param</div>
@code
{
[Parameter]
public int param { get;set; }
}
As you can see, i am trying to pass the param as an argument of my attribute. It does not work. Maybe because when attribute is runned, blazor hasn't parsed parameters.
How can i use a page parameter as an attribute argument ?
Thanks
Upvotes: 0
Views: 508
Reputation: 529
Parameters of an attribute must be known at compiletime. (Hard coded) It makes no difference whether RazorPage or other classes.
The only way to work around this, could be Reflection.
Upvotes: 1