Live Chat Icon For mobile
Live Chat Icon

How do I get the reference or instance of a component?

Platform: Blazor| Category: Components

Component references are used to invoke methods from underlying components. Use the ref attribute for a component and define it filed with the same name and same type of component.

 @page "/"
  
 <Counter IncrementValue="10" @ref="counter"></Counter>
  
 @code {
  
     private Counter counter;    
  
 } 

While the Counter component is rendered, the field counter is populated along with the component instance.

For more information, refer to the link capture-references-to-components.

Share with

Share on twitter
Share on facebook
Share on linkedin

Related FAQs

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

Please submit your question and answer.