Hi Brice,
Thanks for contacting Syncfusion support.
We have checked your reported issue “ref does not work for controls within Tab” with shared sample and during OnAfterRender the content of Tab may not completely initialized. So, we suggest you to use Created event for Tab component to get the reference of its content which have any others components as like Textbox. We have modified your sample for the reference.
|
…
<SfTextBox ID="First" @ref="@firstTextBox" Placeholder="First"></SfTextBox>
<SfTab ID="Tabs">
<TabEvents Created="OnCreate"></TabEvents>
<TabItems>
<TabItem>
<ChildContent>
<TabHeader Text="grid test" />
</ChildContent>
<ContentTemplate>
<SfTextBox ID="Second" @ref="@secondTextBox" Placeholder="Second"></SfTextBox>
</ContentTemplate>
</TabItem>
</TabItems>
</SfTab>
@code
{
SfTextBox firstTextBox;
SfTextBox secondTextBox;
protected override void OnAfterRender(bool firstRender)
{
Console.WriteLine("First = " + firstTextBox?.ToString());
base.OnAfterRender(firstRender);
}
public void OnCreate()
{
Console.WriteLine("Second = " + secondTextBox?.ToString()); /*To get the reference of second Textbox*/
}
} |
Kindly get back to us, if you need further assistance.
Regards
Alagumeena.K