SfTextbox Created event args are always null

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


6 Replies 1 reply marked as answer

UD UdhayaKumar Duraisamy Syncfusion Team April 11, 2022 02:32 PM UTC

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


Attachment: TextBox_8e728ce3.zip

Marked as answer

SZ SZL April 12, 2022 01:47 PM UTC

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!



UD UdhayaKumar Duraisamy Syncfusion Team April 13, 2022 01:09 PM UTC

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




UD UdhayaKumar Duraisamy Syncfusion Team April 19, 2022 05:49 AM UTC

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



SZ SZL replied to UdhayaKumar Duraisamy April 19, 2022 07:20 AM UTC

Hi,

Ok, thank you for the validation.

BR, SZL



UD UdhayaKumar Duraisamy Syncfusion Team April 20, 2022 05:34 AM UTC

Hi SZL,


Most welcome, We are always happy to assist you.


Regards,

Udhaya Kumar D


Loader.
Up arrow icon