I'm trying to pass values from a select control on a blazor layout as they change to the current page. i.e. I have a dropdown that when the values is changed it needs to tell the page (via an event, parameter or cascasding parameter I'm not sure):
So far I have this:
_layout.razor
<div class="page">
<select onchange="OnSiteChanged">
<option value="1">Site 1</option>
<option value="2">Site 2</option>
</select>
</div>
@code{
[Parameter]
public EventHandler SiteChanged{ get; set; }
private void OnSiteChanged(object sender, EventArgs e)
{
SiteChanged.Invoke(this, e);
}
}
and pass it to the underlying page:
pagewithlayout.razor
@code{
[Parameter]
public EventCallback SiteChanged { get; set; }
public async Task OnSiteChanged(EventArgs e){
/do something
}
}
However the event on the page never fires. Any ideas?
@inheritsa common base type, matching the layoutBodyproperty type... ? (I haven't worked with blazor at all though, so I don't know if that idea would work).