How to focus searbox in javascript?

1 Answer 89 Views
SearchBox
Gilberto
Top achievements
Rank 1
Gilberto asked on 24 Jan 2023, 06:26 PM

I have a searchbox in a radwindows. Id like to focus my searchbox on opening the radwindows in javascript. Is it possible?

 

 

1 Answer, 1 is accepted

Sort by
1
Accepted
Rumen
Telerik team
answered on 25 Jan 2023, 04:34 AM

Hi Gilberto,

You can set the focus in the OnClientShow client event of RadWindow as shown below:

        <telerik:RadWindow ID="RadWindow1" runat="server" VisibleOnPageLoad="true" OnClientShow="focusSearchBox">
            <ContentTemplate>
                <telerik:RadSearchBox ID="RadSearchBox1" runat="server"></telerik:RadSearchBox>
            </ContentTemplate>
        </telerik:RadWindow>
        <script type="text/javascript">
            function focusSearchBox() {
                var searchbox =  $find("<%=RadSearchBox1.ClientID %>");
                searchbox.get_inputElement().focus()
            }
        </script>

 

Regards,
Rumen
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Gilberto
Top achievements
Rank 1
commented on 25 Jan 2023, 05:33 PM

Thank you very very much!!!!!!!!!! It works perfectly
Rumen
Telerik team
commented on 26 Jan 2023, 05:52 AM

Cheers :)
Tags
SearchBox
Asked by
Gilberto
Top achievements
Rank 1
Answers by
Rumen
Telerik team
Share this question
or