how to know if ElementReference is present in dom

Viewed 146

Is it possible to tell on onAfterRenderAsync if a certain ElementReference is present in the DOM (rendered) ? I have something like this:

@if (condition) {
<input @ref="elem1" />
}

and on onAfterRenderAsync I need to know if elem1 is rendered, is this possible ( aside from looking at condition ) ?

1 Answers

You can check it like this

if (elem1.Context is not null)
   { 
       //  do something
   }
else
   {
       //  do something
   }
Related