[CLOSED] Pass array to web service

  1. #1

    [CLOSED] Pass array to web service

    Hi,

    I am calling a web service from an aspx page using the following code.

            
            <Store>            
                <ext:Store ID="Store1" runat="server">
                    <Proxy>                    
                        <ext:AjaxProxy Url="~/Services/Search.asmx/Search" Json="true">
                            <Headers>
                                <ext:Parameter Name="Content-Type" Value="application/json" Mode="Value" />
                            </Headers>
                        </ext:AjaxProxy>
                    </Proxy>
                    <Parameters>
                        <ext:StoreParameter Name="Id" Value="Ext.getCmp('txtId').getValue()" Mode="Value" />
                        <ext:StoreParameter Name="type" Value="['S']" Mode="Raw" />
                    </Parameters>
                </ext:Store>
            </Store>

    Web service:

    [WebMethod]
        [ScriptMethod(ResponseFormat = ResponseFormat.Json, XmlSerializeString = false)]
        public ExtJsGrid<SearchResultsViewModel> Search
        (
           int start, string limit, string sort,
           string Id, string[] type
        )
        {
         }
    I want to change type parameter to dynamically get the value from a code behind type (e.g. <%=type%>) instead of hard coding it as ['S'].

    I tried different options but no luck so far. Can you please advice?

    Thanks
    Last edited by Daniil; Mar 25, 2015 at 1:32 PM. Reason: [CLOSED]
  2. #2
    Hi @Maitreya,

    Before suggesting anything, I should understand the requirement better.

    Please clarify how do you manage the type value in code behind? How/when is it going to be changed?
  3. #3
    Hi @Daniil,

    "type" (char/string variable) is getting set from a query string value in the code behind page. It will only be set during the page load and will never be changed.

    Thanks.
  4. #4
    Thanks. I would recommend to add a parameter during the page load as well.
    string[] type = new string[] { "1", "2" };
                   
    store.Parameters.Add(new StoreParameter
    {
        Name = "type",
        Value = JSON.Serialize(type),
        Mode = ParameterMode.Raw
    });
  5. #5
    That's great! Thanks a lot.

Similar Threads

  1. DirectMethod - how to pass an array parameter
    By tcunha in forum 2.x Help
    Replies: 3
    Last Post: May 21, 2014, 10:17 AM
  2. pass object to web service with loader
    By Taz in forum 2.x Help
    Replies: 0
    Last Post: Aug 03, 2012, 11:08 AM
  3. Need Help Using a Web Service !
    By metallica87 in forum 1.x Help
    Replies: 2
    Last Post: Mar 19, 2012, 3:25 AM
  4. Replies: 0
    Last Post: Feb 16, 2011, 12:41 PM
  5. [CLOSED] To pass an Array using ajaxmethod
    By speedstepmem3 in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Aug 31, 2009, 7:58 AM

Tags for this Thread

Posting Permissions