View Full Version : [CLOSED] Pass array to web service

Mar 25, 2015, 9:02 AM

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

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

Web service:

[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?


Mar 25, 2015, 11:10 AM
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?

Mar 25, 2015, 11:52 AM
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.


Mar 25, 2015, 12:16 PM
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

Mar 25, 2015, 12:52 PM
That's great! Thanks a lot.