Custom data in RadComboBoxContext

3 posts, 0 answers
  1. Simon
    Simon avatar
    8 posts
    Member since:
    Apr 2009

    Posted 06 Oct 2010 Link to this post

    Hi,

    I want to use load-on-demand with a web service to filter the results of my combo box as the user types in it. I have looked at the example here:
    http://www.telerik.com/help/aspnet-ajax/combo_loadondemandwebservice.html

    The example works fine if I only want to filter the results according to the text the user has typed. However I also need to be able to access other criteria from the user session with which to filter the data. Specifically, I need to know who the user is logged in as, so I can pre-filter the results based on which ones they are allowed to see. Their userid is held in Session state and I need to be able to retrieve it in order to narrow the results further.

    The RadComboBoxContext has no property which allows me to get at the Session state, so how can I do so from within the web service method? I have seen posts elsewhere which suggest adding custom data to the context, but how is this done? How do I get my Session state data into the context in the first place?

    Thanks,
    S.
  2. Simon
    Simon avatar
    8 posts
    Member since:
    Apr 2009

    Posted 06 Oct 2010 Link to this post

    I've sorted it.

    You have to use the OnClientItemsRequesting attribute of the RadComboBox to specify a client function, which creates an appropriate dictionary item in the context object passed to it. The client function is then inserted into the page at runtime using ClientScript.RegisterClientScriptBlock, enabling you to hardcode whatever session variables you need directly into the client function. The web service method can then investigate the context object and find the item created by the client function.

  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Otto Neff
    Otto Neff avatar
    36 posts
    Member since:
    Jul 2011

    Posted 09 Jan 2014 Link to this post

    Hi Simon,

    thanks for this nice hint. Works like a charm....

    Example for addtional ClientID in RadComboBoxContext

    box.OnClientItemsRequesting = "function(sender,args){args.get_context()['ClientID'] = '" + box.ClientID + "';}";

    Cheers Otto.
Back to Top