Q:

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

0

This code will help you to understand how to pass multiple parameters using cascading values in Blazor by name.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

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

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now