This code will help you to understand how to pass multiple parameters using cascading values in Blazor by name.
When creating a cascading value, specify the name attribute in the CascadingValue component. Then specify the name in the child component.
Parent component
@page "/cascading" <CascadingValue Value="@Id" Name="EmpId"> <CascadingValue Value="@Name" Name="EmpName"> <CascadingChild></CascadingChild> </CascadingValue> </CascadingValue> @code{ int Id = 1; string Name = "Test"; }
Child component
<p>Employee Id:@EmployeeId </p> <p>Employee Name:@EmployeeName </p> @code{ [CascadingParameter(Name = "EmpId")] private int EmployeeId { get; set; } [CascadingParameter(Name = "EmpName")] private string EmployeeName { get; set; } }
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
When creating a cascading value, specify the name attribute in the CascadingValue component. Then specify the name in the child component.
Parent component
Child component
need an explanation for this answer? contact us directly to get an explanation for this answer