Articles in this section
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.

Autocomplete display toggle

Figure 1: Show or Hide AutoComplete on Toggle button click 

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied