Hello,
I have a simle textbox:
<SfTextBox TabIndex="1" @ref="textbox0" ID="textbox" @bind-Value="_testModel.Value1" Created="CreatedHandler"></SfTextBox>
private void CreatedHandler(Object args)
{
// args null here
}
I would like access to the control inside the CreateHandler method dynamically, so not at this way: textbox0.[xy]
I would like access to the source control trough the args object, but it is always null.
In my future plan I have 5 textbox controls that uses the same Created event and I need access to tabindex value inside CreatedHandler method.
Thank you for help!
BR, SZL
Hi SZL,
As you requested we have created a sample that has 5 textbox controls that use the same Created event and we can access to tabindex value inside the CreatedHandler method. Please find the code snippet and sample below.
<SfTextBox TabIndex=0 @ref="textbox0" ID="textbox1" @bind-Value="_testModel.Value1" Created="(args) => CreatedHandler(args,textbox0)"></SfTextBox>
<br /> <SfTextBox TabIndex=1 @ref="textbox1" ID="textbox2" @bind-Value="_testModel.Value2" Created="(args) => CreatedHandler(args,textbox1)"></SfTextBox>
<br /> <SfTextBox TabIndex=2 @ref="textbox2" ID="textbox3" @bind-Value="_testModel.Value3" Created="(args) => CreatedHandler(args,textbox2)"></SfTextBox>
@code{ SfTextBox textbox0; SfTextBox textbox1; SfTextBox textbox2;
TextModel _testModel = new TextModel(); public class TextModel { public string Value1; public string Value2; public string Value3;
} private void CreatedHandler(Object args,SfTextBox textBoxRef) { var Tabindex = textBoxRef.TabIndex; } }
|
Regards,
Udhaya Kumar D
Thank you, this will be good.
In the future you will not add the sender object to the args parameter to the Created event? (feature request)
In this case the code will be much sorter and not need create reference objects.
Thank you!
Hi SZL,
We are validating the requested requirement on our end. We will update the further details in two business days (19th April 2022).
Regards,
Udhaya Kumar D
Hi SZL,
On further validation of your requirement, we found that there is a limited use case for the required scenario. So we request you to use the suggested workaround solution provided in the previous update.
Regards,
Udhaya Kumar D
Hi,
Ok, thank you for the validation.
BR, SZL
Hi SZL,
Most welcome, We are always happy to assist you.
Regards,
Udhaya Kumar D