Loading items from WebService

2 posts, 0 answers
  1. Alex
    Alex avatar
    23 posts
    Member since:
    Nov 2013

    Posted 03 Mar 2016 Link to this post

    I have a textbox and a listbox that displays customer information. On page load my listbox populates just fine from a webmethod and shows in a ClientItemTemplate. I want to be able to call this webmethod from code-behind and repopulate the listbox based on what text is typed in the textbox (onkeyup). The problem is I keep getting the error "JavaScript runtime error: Object doesn't support property or method 'get_parent'"


    Here is the server-side code:

    <WebMethod()> _
        Public Shared Function GetCustomers() As RadListBoxItemData()
            Dim data As DataTable = GetData("248")
            Dim result As New List(Of RadListBoxItemData)()
            For i As Integer = 0 To data.Rows.Count - 1
                Dim itemData As New RadListBoxItemData()
                Dim FullName As String = data.Rows(i)("FName").ToString() & " " & data.Rows(i)("LName").ToString()
                itemData.Text = data.Rows(i)("CPhone").ToString()
                itemData.Value = data.Rows(i)("CPhone").ToString()
                itemData.Attributes.Add("FullName", FullName)
                itemData.Attributes.Add("Phone", data.Rows(i)("CPhone").ToString().Insert(0, "(").Insert(4, ") ").Insert(9, "-"))
                '--Determine opt-in icon
                Select Case data.Rows(i)("OptIn").ToString()
                    Case -1
                        itemData.Attributes.Add("OptIn", "<img alt='Opted-In' src='images_zw/OptIn_OptedIn.png' />")
                    Case 0
                        itemData.Attributes.Add("OptIn", "<img alt='Blocked / Opted-Out' src='images_zw/OptIn_Blocked.png' />")
                    Case 1
                        itemData.Attributes.Add("OptIn", "<img alt='Pending Opt-In' src='images_zw/OptIn_Pending.png' />")
                    Case 2
                        itemData.Attributes.Add("OptIn", "")
                End Select
            Return result.ToArray()
        End Function


    Here is my client-side code:

    <script type="text/javascript">
            function Generate()
                var listbox = $find("<%= lstContacts.ClientID%>");
                var result = PageMethods.GetCustomers(function (response) {
                    response.forEach(function (listitem) {
            <div><telerik:RadTextBox runat="server" id="txtSearch" AutoPostBack="False" onkeyup="Generate();" Text="248"></telerik:RadTextBox></div>
                <telerik:RadListBox runat="server" ID="lstContacts" width="300" height="500" AutoPostBack="False">
                        <div class="Search_Conversation_Container">
                            <div class="Search_OptIn">
                                #= Text #
                    <WebServiceSettings Path="testlist.aspx" Method="GetCustomers"></WebServiceSettings>

  2. Alex
    Alex avatar
    23 posts
    Member since:
    Nov 2013

    Posted 03 Mar 2016 in reply to Alex Link to this post

    In the javascript I have tried both .insertItems(response) and .add(listitem) and both result in the same get_parent error
Back to Top