Live Chat Icon For mobile
Live Chat Icon

How do you pass multiple parameters using cascading values in Blazor by name?

Platform: Blazor| Category: Components

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; }
}

Reference link

https://chrissainty.com/understanding-cascading-values-and-cascading-parameters/

Share with

Related FAQs

Couldn't find the FAQs you're looking for?

Please submit your question and answer.