Category / Section
How to Show or Hide the AutoComplete control from client side script?
1 min read
Description
You can show or hide AutoComplete element using client-side API in the web page.
Solution
You can show or hide the AutoComplete control from client side script using the setVisible(bool) API method. When the setVisible() is false then the control is hidden from the web page.
Refer to the following code example to show or hide the control from script.
ASPX
<ej:Autocomplete ID="AutoComplete" runat="server" DataTextField="Text" DataUniqueKeyField="ID" /> <br /> <ej:ToggleButton runat="server" ID="Toggle" ActiveText="Show Control" DefaultText="Hide Control" ClientSideOnClick="OnClick"></ej:ToggleButton>
JavaScript
<script type="text/javascript"> function OnClick(args) { var autocompObj =$("#<%=AutoComplete.ClientID%>").data("ejAutocomplete"); if (args.isChecked) autocompObj.setVisible(false); else autocompObj.setVisible(true); } </script>
The following screenshot illustrates the output on toggle button click.
Figure 1: Show or Hide AutoComplete on Toggle button click