This is a migrated thread and some comments may be shown as answers.

Check to see if autocomplete has no value

1 Answer 184 Views
AutoCompleteBox
This is a migrated thread and some comments may be shown as answers.
Kevin
Top achievements
Rank 1
Kevin asked on 02 Jul 2015, 05:40 PM

I am trying to check to see if the autocomplete box has no value before I go on in code, but the 2 methods I tried do not seem to work. I have it in single mode selection and getting the value fine but when checking for it, the code always escapes to else statement.

 

If txtItemSearch.Entries(0).Value = String.Empty Then
           ScriptManager.RegisterClientScriptBlock(Page, GetType(Page), "OpenWindow", "alert('You must specify an administrator.');", True)
       Else
           Dim adminId As Integer = Convert.ToInt32(txtItemSearch.Entries(0).Value)
           Dim locationId As String = ddlLocations.SelectedValue
           'Dim siteAdmin As Integer = boolToInt(chkSiteAdmin.Checked)
           'Dim contact As Integer = boolToInt(chkContact.Checked)
           'Dim email As Integer = boolToInt(chkEmail.Checked)
 
 
If txtItemSearch.Entries.count < 0 Then
           ScriptManager.RegisterClientScriptBlock(Page, GetType(Page), "OpenWindow", "alert('You must specify an administrator.');", True)
       Else
           Dim adminId As Integer = Convert.ToInt32(txtItemSearch.Entries(0).Value)
           Dim locationId As String = ddlLocations.SelectedValue
           'Dim siteAdmin As Integer = boolToInt(chkSiteAdmin.Checked)
           'Dim contact As Integer = boolToInt(chkContact.Checked)
           'Dim email As Integer = boolToInt(chkEmail.Checked)
 
 
<div class="div100">
           <telerik:RadAutoCompleteBox ID="txtItemSearch" runat="server" Width="260px" OnClientRequesting="requesting" AllowCustomEntry="false" DropDownPosition="Automatic" CssClass="centAutocomplete"
                   EmptyMessage="Enter Last Name First Name to Search"  InputType="Text"  HighlightFirstMatch="true" TextSettings-SelectionMode="Single" DropDownWidth="250px">
                   <WebServiceSettings path="../AutoComplete.asmx" Method="FindAdmin" />
           </telerik:RadAutoCompleteBox>
           <asp:HiddenField ID="HFAdminId" runat="server" />
       </div>

 

1 Answer, 1 is accepted

Sort by
0
Bozhidar
Telerik team
answered on 07 Jul 2015, 07:42 AM
Hi,

The entries collection count never goes below 0, so the following statement will never be true:
If txtItemSearch.Entries.count < 0

When the AutoCompleteBox is empty, the entries collection has a count of exactly 0, so your check should be:
If txtItemSearch.Entries.count = 0


Regards,
Bozhidar
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
AutoCompleteBox
Asked by
Kevin
Top achievements
Rank 1
Answers by
Bozhidar
Telerik team
Share this question
or