Web Service- how to add data to context object

7 posts, 1 answers
  1. Andrew
    Andrew avatar
    3 posts
    Member since:
    Mar 2008

    Posted 02 Apr 2008 Link to this post

    When you load on demand from a Web Service, is there a way to add fields to the "context" argument? In my test it contains only "NumberOfItems" and "Text".
    Ideally I would like to gather more info about the calling RadCombo. Help anyone?

    Thank you
    Andrew
  2. Answer
    Nikolay
    Admin
    Nikolay avatar
    3997 posts

    Posted 02 Apr 2008 Link to this post

    Hi Andrew,

    You can refer to the Populate from WebService example and see how the text of the input field is passed to the context object. The same way you can pass other information about the combobox:

    function itemRequesting(sender, eventArgs)
    {
    var context = eventArgs.get_context();
    context["Filter"] = sender.get_text();
    }

    Hope this helps.

    Regards,
    Nick
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Andrew
    Andrew avatar
    3 posts
    Member since:
    Mar 2008

    Posted 02 Apr 2008 Link to this post

    Great, thanks
  5. Nesim
    Nesim avatar
    7 posts
    Member since:
    May 2008

    Posted 22 May 2008 Link to this post

    Hi,
    I did all like the sample but i get the failed error. No explaining :( 
    The HTML Codes:
    <telerik:RadComboBox ID="rcbMusteriler" runat="server" CustomText="True" AutoPostBack="False" 
     EmptyMessage="Müşteri İsmi Giriniz" EnableLoadOnDemand="True"   
    EnableVirtualScrolling="True" LoadingMessage="Arıyor ..." 
     MarkFirstMatch="True" OnSelectedIndexChanged="rcbMusteriler_SelectedIndexChanged"   
    OnClientItemsRequesting="itemRequesting" OpenDropDownOnLoad="True">  
        <WebServiceSettings Method="GetMusteriler" Path="Musteriler.asmx" /> 
                <CollapseAnimation Duration="200" Type="OutQuint" /> 
        </telerik:RadComboBox> 
    The JavaScript Codes:
    <script language="javascript" type="text/javascript">  
        function itemRequesting(sender, eventArgs)  
    {  
        var context = eventArgs.get_context();  
        context["Filter"] = sender.get_text();  
    }  
    </script>  
             
    And The WebService Codes:
    1 <Script.Services.ScriptService()> _  
    2    Public Class WebServiceName  
    3         Inherits WebService  
    4         <WebMethod()> _  
    5         Public Function GetMusteriler(ByVal context As ObjectAs Telerik.Web.UI.RadComboBoxItemData()  
    6             Dim oDatas(2) As Telerik.Web.UI.RadComboBoxItemData  
    7             Dim sMstAdi As String = context.ToString  
    8             If sMstAdi.Length > 2 Then 
    9                 Dim ta As New DataAccess.KULLANICITableAdapters.ButunKullanicilarTableAdapter  
    10                 Dim dt As DataAccess.KULLANICI.ButunKullanicilarDataTable = ta.GetDataByAdSoyad(sMstAdi)  
    11                 ReDim oDatas(dt.Rows.Count - 1)  
    12                 Dim dr As DataAccess.KULLANICI.ButunKullanicilarRow  
    13                 For i As Integer = 0 To dt.Rows.Count - 1 
    14                     dr = dt.Rows(i)  
    15                     oDatas(i).Text = dr.ADISOYADI  
    16                     oDatas(i).Value = dr.KULLANICI_ID  
    17                 Next 
    18             End If 
    19             Return oDatas  
    20         End Function 
    21     End Class 
  6. Veselin Vasilev
    Admin
    Veselin Vasilev avatar
    2992 posts

    Posted 22 May 2008 Link to this post

    Hello Nesim,

    I think that the problem might be related to the fact that you are using context.ToString()

    I suggest that you examine these online resources:
    I hope this helps.

    Sincerely yours,
    Veskoni
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  7. Nesim
    Nesim avatar
    7 posts
    Member since:
    May 2008

    Posted 22 May 2008 Link to this post

    Hello Veskoni,
    I can't debug it what context returns becasue it doesn't hit when i breakpoint in vs. the event doesn't raise. webservice event.  i tried to convert idictionary the context data. 

    Dim dicCon As IDictionary = context
    Dim sMstAdi As String = dicCon("Filter").ToString


    Nothing different. Same Problem. The server method "GetMusteriler" failed.
    I got the text from javascript. 

    alert(sender.get_text());


    it works ... but i need to more details.

    How can i get detailed error exception? Or Stack trace ...

    Thanks a lot
  8. Veselin Vasilev
    Admin
    Veselin Vasilev avatar
    2992 posts

    Posted 23 May 2008 Link to this post

    Hi Nesim,

    You can subscribe to the OnClientItemsRequestFailed event and examine the error message by calling eventArgs.get_errorMessage() method.

    Regards,
    Veskoni
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017