Autofocus Example

Dear All,

Any example how to implement autofocus at SfTextbox ?

I'm trying to use FocusIn() at OnAfterRender() but no luck.

Thanks.

Regards,
Handi Rusli

3 Replies

SN Sevvandhi Nagulan Syncfusion Team April 16, 2020 06:53 AM UTC

Hi Handi,  
  
Greetings from Syncfusion support.  

You can focus TextBox Component on the initial rendering. We noticed that you have tried to focusing TextBox before our Component rendering in DOM. 
 
So, we suggest you to do focus in Created event of TextBox Component instead of OnAfterRender.

Code example: 
 
    <SfTextBox @ref="textboxObj" Placeholder='First Name' Created="onCreated"></SfTextBox> 
 
@code{ 
    SfTextBox textboxObj; 
 
    public void onCreated() 
    { 
        textboxObj.FocusIn(); 
    } 
} 

Kindly let us know if you need further assistance on this.  
 
Regards,
Sevvandhi N
 



HA Handi April 16, 2020 12:14 PM UTC

Dear Sevvandhi,

It works like a champ, thank you.

Regards,
Handi Rusli


SN Sevvandhi Nagulan Syncfusion Team April 17, 2020 05:29 AM UTC

Hello Handi, 

Thanks for the update. Please let us know if you need any other further assistance on this. 

Regards, 
Sevvandhi N 


Loader.
Up arrow icon