Autocomplete with webmethods

4 posts, 0 answers
  1. Fabio Cirillo
    Fabio Cirillo avatar
    180 posts
    Member since:
    Jan 2010

    Posted 16 Jan 2013 Link to this post

    hi
    i've this object:

    <telerik:RadAutoCompleteBox ID="RadAutoCompleteBox1" Runat="server"
    Delimiter="" DropDownHeight="150px" DropDownWidth="270px" Filter="StartsWith"
    InputType="Text" Width="270px" EmptyMessage="Inserisci la tua città"
    Skin="Sunset">
    <WebServiceSettings Method="Getcity" Path="index.aspx" />
    </telerik:RadAutoCompleteBox>

    I have three questions to ask:

    1)

    i've this code into vbnet:

    <WebMethod()>
    Public Shared Function Getcity(context As Object) As AutoCompleteBoxData
    Dim searchString As String = DirectCast(context, Dictionary(Of String, Object))("Text").ToString()
    Dim data As DataTable = Getcomuni(searchString)
    Dim result As New List(Of AutoCompleteBoxItemData)()
    For Each row As DataRow In data.Rows
    Dim childNode As New AutoCompleteBoxItemData()
    childNode.Text = row("descrizione").ToString()
    childNode.Value = row("id").ToString()
    result.Add(childNode)
    Next
    Dim res As New AutoCompleteBoxData()
    res.Items = result.ToArray()
    Return res
    End Function
    Private Shared Function Getcomuni(ByVal text As String) As DataTable
    Dim adapter As New SqlDataAdapter("SELECT * from Tab_comuni WHERE descrizione LIKE @text + '%'", ConfigurationManager.ConnectionStrings("TrycontactString").ConnectionString)
    adapter.SelectCommand.Parameters.AddWithValue("@text", text)
    Dim data As New DataTable()
    adapter.Fill(data)
    Return data
    End Function

    but when I try to search for a city, nothing shows the dropdown does not appear.

    2)
    Why having the object raddecoration and thus eliminating any entry in AutoCompleteBox propriotà skin object, you can not see the edges of the round?

    3)
    How come when the focus is on the AutoCompleteBox, the edges of the object are not shown

    Thanks you



  2. Nencho
    Admin
    Nencho avatar
    1458 posts

    Posted 21 Jan 2013 Link to this post

    Hello Fabio,

    I can see that you are correctly implementing the population of the RadAutoCompleteBox control via Page Method. I have prepared a sample project for you, base on the provided snippet of code, demonstrating the behavior at my end. Please make sure that the data returned from your database is correct. 

    As for your second question, the styles in the  RadFormDecorator would apply on a native input element, which is not the case with RadAutoCompleteBox.

    In RadAutoCompleteBox, the container is made to look like an input, but it's not. Therefore, the styles defined with the decorator, are not correctly applied on the RadAutoCompleteBox. I can suggest that you use custom css style, which would make the corners of the control rounded. I have implemented the above suggestions in the provided sample.

    Please give it a try and let us know if it works properly at your end.

    Regards,
    Nencho
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Fabio Cirillo
    Fabio Cirillo avatar
    180 posts
    Member since:
    Jan 2010

    Posted 21 Jan 2013 Link to this post

    Hello Nencho,

    i used your example code for the test. But the autocompletebox dont function.
    this is code behind that i use to load the record into radcombo

    Dim adapter As New SqlDataAdapter("SELECT * from Tab_categorie WHERE descrizione LIKE @text + '%'", ConfigurationManager.ConnectionStrings("TrycontactString").ConnectionString)
    adapter.SelectCommand.Parameters.AddWithValue("@text", text)
     
    Dim data As New DataTable()
    adapter.Fill(data)

    how can to use this code in your axample? 

    dont see the corners rounded.
    i seen that he has written into code aspx a style:
    .RadAutoCompleteBox .racTokenList {
        border-radius: 5px;
    }

    this is the css code for to get the corners rounded?
  5. Nencho
    Admin
    Nencho avatar
    1458 posts

    Posted 24 Jan 2013 Link to this post

    Hello Fabio,

    With the usage of the provided css style, the corners of the RadAutoCompleteBox control should get rounded. I have recorded a video, demonstrating the behavior at my end. Could you specify which browser you use?

    In addition, I noticed that you mentioned that you use the provided snippet if code to populate the combobox. Could you specify which control you use? Lastly, regardless the approach you use to populate the control, the style should apply and make the corners rounded.

    Greetings,
    Nencho
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Back to Top