Parameters for WebServiceSettings Method

6 posts, 0 answers
  1. Mickael
    Mickael avatar
    24 posts
    Member since:
    Oct 2014

    Posted 11 Oct 2014 Link to this post

    Hi,
    I am adding RadAutoCompleteBox dynamically to my page.
    The autocompleteboxes are using a PageMethod to get the results for the dropdown.
    Each autocompletebox is related to a different type, but I cannot implement a search function for each type because these are dynamic too.
    I know the Type-autocompletebox relation, but I cannot differentiate them in the PageMethod.
    Is there a way to pass a parameter to the PageMethod through the WebServiceSettings of the AutoCompleteBox ?

    I tried to use the OnClientDropDownOpening client event, but it is fired after the search completed, so it is too late already.
  2. Nencho
    Admin
    Nencho avatar
    1457 posts

    Posted 14 Oct 2014 Link to this post

    Hello Mickael,

    You could use the OnClientRequesting client-side event of the RadAutoCompleteBox, in order to use the context and pass any custom parameters to the WebMethod. Please consider the below implementation :

    javascript
    <script type="text/javascript">
           function OnClientRequesting(sender, args) {
               var context = args.get_context()
               context["CustomParam"] = "CutomValue";
           }
       </script>

    code-behind
    [WebMethod]
       public static AutoCompleteBoxData GetCompanyNames(RadAutoCompleteContext context)
       {
           string CustomParamValue = context["CustomParam"].ToString();


    Regards,
    Nencho
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Mickael
    Mickael avatar
    24 posts
    Member since:
    Oct 2014

    Posted 14 Oct 2014 in reply to Nencho Link to this post

    I am trying to use the OnClientRequesting, but it looks like I am doing something wrong because it is not firing
    This is what I have so far:

    _autoCompleteBox = new RadAutoCompleteBox();
    _autoCompleteBox.ID = String.Format("Extra_RdtCmpltBx_{0}_{1}", TypeData.Name, ID);
    _autoCompleteBox.Filter = RadAutoCompleteFilter.StartsWith;
    _autoCompleteBox.DropDownPosition = RadAutoCompleteDropDownPosition.Automatic;
    _autoCompleteBox.AllowCustomEntry = true;
    _autoCompleteBox.InputType = RadAutoCompleteInputType.Text;
    _autoCompleteBox.OnClientRequesting = "OnClientRequesting";
    _autoCompleteBox.WebServiceSettings.Method = "GetResultsByType";
    _autoCompleteBox.WebServiceSettings.Path = "Popup_Add.aspx";
    _autoCompleteBox.TextSettings.SelectionMode = RadAutoCompleteSelectionMode.Single;
    _autoCompleteBox.Entries.Add(new AutoCompleteBoxEntry(Name));

    function OnClientRequesting(sender, args) {
        debugger;
        var context = args.get_context()
        context["CustomParam"] = "CutomValue";
    }

    [WebMethod]
    public static AutoCompleteBoxData GetResultsByType(RadAutoCompleteContext context)
    {
        string searchString = context["Text"].ToString();
     
        string CustomParamValue = context["CustomParam"].ToString();
    }

  5. Nencho
    Admin
    Nencho avatar
    1457 posts

    Posted 15 Oct 2014 Link to this post

    Hello Mickael,

    I have created a runnable sample for you, demonstrating the implementation of the previous suggested approach. You can give it a try at your end and let us know if the issue still persist.

    Note : dll files are removed from the attachment.

    Regards,
    Nencho
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  6. Mickael
    Mickael avatar
    24 posts
    Member since:
    Oct 2014

    Posted 15 Oct 2014 in reply to Nencho Link to this post

    Thanks, it works now
  7. sun
    sun avatar
    2 posts
    Member since:
    Mar 2015

    Posted 10 Mar 2015 in reply to Mickael Link to this post

    Hello Mickael,
    I alse download Nencho's .zip,but it has same problem.I do not know why?Can you help me?
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017