New to Telerik UI for ASP.NET AJAX? Download free 30-day trial

OnCustomParameter Event

CustomParameter event allows you to convert the request parameters to a format suitable for the remote service. By default the data source sends the parameters using jQuery's conventions. The event is commonly used to pass additional parameters to the server. It is important to note that the names of the custom parameters should match the method's arguments names.

The event is fired after the request started but before the data is requested. This way you can set custom parameters that will be sent to the server. The following table lists all the public methods of the event.

Method Description
get_data The model which will be sent to the remote service. The value specified in the data field of the transport settings (create, read, update or destroy) is included as well.
get_type The type of the request which the data source makes. The supported values are "create", "read", "update" and "destroy".
get_parameterFormat Get the custom parameters that will be sent to the server.
set_parameterFormat Set the custom parameters that will be sent to the server.

The following example demonstrates how to use CustomParameter client event and pass parameter to a WebMethod.

<form id="form1" runat="server">
    <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
            <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js" />
            <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQuery.js" />
            <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQueryInclude.js" />
    <script type="text/javascript">
        function ParameterMap(sender, args) {
            args.set_parameterFormat("{ 'productName': 'Filo Mix' }");

    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
    <telerik:RadGrid RenderMode="Lightweight" ID="RadGrid1" runat="server" ClientDataSourceID="RadClientDataSource1" AutoGenerateColumns="false" PageSize="4">
        <MasterTableView CommandItemDisplay="Top">
                <telerik:GridBoundColumn DataField="ProductName" HeaderText="Product Name"></telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="UnitPrice" HeaderText="Unit Price"></telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="UnitsInStock" HeaderText="Units In Stock"></telerik:GridBoundColumn>

    <telerik:RadClientDataSource ID="RadClientDataSource1" runat="server">
        <ClientEvents OnCustomParameter="ParameterMap" />
            <WebServiceDataSourceSettings BaseUrl="WebPageTest.aspx/">
                <Select Url="GetData" RequestType="Post" DataType="JSON" ContentType="application/json; charset=utf-8" />
            <Model ID="ProductID">
                <telerik:ClientDataSourceModelField FieldName="ProductID" DataType="Number" />
                <telerik:ClientDataSourceModelField FieldName="ProductName" DataType="String" />
                <telerik:ClientDataSourceModelField FieldName="UnitPrice" DataType="Number" />
                <telerik:ClientDataSourceModelField FieldName="UnitsInStock" DataType="Number" />
public static IQueryable<Model.ReadWrite.Product> GetData(string productName)
    NorthwindReadWriteEntities dbContext = new NorthwindReadWriteEntities();

    var result = from products in dbContext.Products
                    where products.ProductName == productName
                    select products;
    return result;

See Also

In this article