Check to see if autocomplete has no value

2 posts, 0 answers
  1. Kevin
    Kevin avatar
    265 posts
    Member since:
    Jun 2011

    Posted 02 Jul 2015 Link to this post

    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>

     

  2. Bozhidar
    Admin
    Bozhidar avatar
    1101 posts

    Posted 07 Jul 2015 Link to this post

    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
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top