This is a migrated thread and some comments may be shown as answers.

How to pass parameter to webservice when using Load on demand

1 Answer 64 Views
Rotator
This is a migrated thread and some comments may be shown as answers.
Edwin
Top achievements
Rank 1
Edwin asked on 23 Sep 2011, 07:07 AM
I followed the example in live demo and found that the signature of the webservice method must be

public RadRotatorItemData[] GetRotatorData(int itemIndex)

Does that mean there is no way to pass any custom parameter to the webservice method?

Regards
Edwin

1 Answer, 1 is accepted

Sort by
0
Accepted
Slav
Telerik team
answered on 28 Sep 2011, 10:55 AM
Hi Edwin,

You can pass a custom parameter to the WebService method by following these steps:

  1. Attach a handler to the client event OnClientItemsRequesting and implement it as demonstrated below:
    <script type="text/javascript">
        function OnClientItemsRequesting(oRotator, args)
        {
            args.set_argument("value");
        }
    </script>
    The string "value" will be passed to the parameter argument of the WebService method, when a request is made.
  2. Then you can get the value in the WebService as shown in the following code sample:
    [WebMethod]
    public RadRotatorItemData[] GetRotatorData(int itemIndex, string argument)
    {
      ...
    }
    Please note that the name of the argument should be kept the same, in order to ensure proper functionality.

All the best,
Slav
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
Tags
Rotator
Asked by
Edwin
Top achievements
Rank 1
Answers by
Slav
Telerik team
Share this question
or