1. #1
    Sencha User
    Join Date
    Sep 2013
    Posts
    6
    Vote Rating
    0
    kvbhaskar.net@gmail.com is on a distinguished road

      0  

    Default Unanswered: Post Param data to ASP.Net Web service

    Unanswered: Post Param data to ASP.Net Web service


    Hi, I would like to know how to pass parameters to asp.net web services. I am new to EXTJs so appreciate if you provide with sample code.

    my requirement is much simple and standard, take search values and on button click fill data into grid. please advice if I am making any mistake seeing below code.

    On button click how to make call to service with parameters?

    Click event:
    buttons: [{ text: 'Search', id: 'Search', listeners: {
    click: function () {
    var st = Ext.data.StoreManager.lookup('mystore');
    st.proxy.extraParams = { 'param1': 'test', 'param2': 'test2' };
    st.load();
    }}}]

    Store:
    var store = new Ext.data.JsonStore({
    autoLoad: true,
    storeId: 'mystore',
    model: 'Book',
    proxy: new Ext.data.HttpProxy({
    type: 'ajax',
    method: 'POST',
    url: "Service2.asmx/GetPeople",
    headers: {'Content-type': 'application/json'},
    writer: {type: 'json'},
    reader: {type: 'json',root: 'd',idProperty: 'SEQ_NO'}
    })
    });

    Grid:
    var grid = Ext.create('Ext.grid.Panel', {
    frame: true,
    store: store,
    columns: [
    { text: "SEQ_NO", width: 100, dataIndex: 'SEQ_NO' },
    { text: "column2", width: 180, dataIndex: 'column2' },
    { text: "column3", width: 115, dataIndex: 'column3' },
    { text: "column4", width: 100, dataIndex: 'column4' }
    ],
    renderTo: 'example-grid',
    width: 1230,
    height: 200

    });

    Web Service:
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    [ScriptService]
    public class Service : System.Web.Services.WebService
    {
    [WebMethod]
    [ScriptMethod(ResponseFormat = ResponseFormat.Json, UseHttpGet = true, XmlSerializeString = false)]
    public List<Person> GetPeople(string param1, string param2)
    {
    string SProc = "PROC_NAME";
    return Factory.GetPeopleController().GetPeople(SProc);
    }
    }

  2. #2
    Sencha User existdissolve's Avatar
    Join Date
    Jan 2010
    Location
    Kansas
    Posts
    522
    Vote Rating
    86
    Answers
    31
    existdissolve is just really nice existdissolve is just really nice existdissolve is just really nice existdissolve is just really nice existdissolve is just really nice

      0  

    Default


    To help others help you, I would suggest a few things:
    1. Cleanup and properly format your code. With all of the commented out bits, plus the lack of formatting, it's incredibly difficult to read
    2. Share the data (again, properly formatted) that is being returned from the server

  3. #3
    Sencha User
    Join Date
    Sep 2013
    Posts
    6
    Vote Rating
    0
    kvbhaskar.net@gmail.com is on a distinguished road

      0  

    Default


    thank you for your response, sure definetly will help others, today is my first day so I can't answer other questions.

    as per your suggestion, I seperate it out my code and see it below:

    Hi, I would like to know how to pass parameters to asp.net web services. I am new to EXTJs so appreciate if you provide with sample code.

    my requirement is much simple and standard, take search values and on button click fill data into grid. please advice if I am making any mistake seeing below code.

    Issue: unable to make call to service on button click.

    Click event:
    buttons: [{ text: 'Search', id: 'Search', listeners: {
    click: function () {
    var st = Ext.data.StoreManager.lookup('mystore');
    st.proxy.extraParams = { 'param1': 'test', 'param2': 'test2' };
    st.load();
    }}}]

    Store:
    var store = new Ext.data.JsonStore({
    autoLoad: true,
    storeId: 'mystore',
    model: 'Book',
    proxy: new Ext.data.HttpProxy({
    type: 'ajax',
    method: 'POST',
    url: "Service2.asmx/GetPeople",
    headers: {'Content-type': 'application/json'},
    writer: {type: 'json'},
    reader: {type: 'json',root: 'd',idProperty: 'SEQ_NO'}
    })
    });

    Grid:
    var grid = Ext.create('Ext.grid.Panel', {
    frame: true,
    store: store,
    columns: [
    { text: "SEQ_NO", width: 100, dataIndex: 'SEQ_NO' },
    { text: "column2", width: 180, dataIndex: 'column2' },
    { text: "column3", width: 115, dataIndex: 'column3' },
    { text: "column4", width: 100, dataIndex: 'column4' }
    ],
    renderTo: 'example-grid',
    width: 1230,
    height: 200

    });

    Web Service:
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    [ScriptService]
    public class Service : System.Web.Services.WebService
    {
    [WebMethod]
    [ScriptMethod(ResponseFormat = ResponseFormat.Json, UseHttpGet = true, XmlSerializeString = false)]
    public List<Person> GetPeople(string param1, string param2)
    {
    string SProc = "PROC_NAME";
    return Factory.GetPeopleController().GetPeople(SProc);
    }
    }

  4. #4
    Sencha User
    Join Date
    Sep 2013
    Posts
    6
    Vote Rating
    0
    kvbhaskar.net@gmail.com is on a distinguished road

      0  

    Default


    I figure it out and working as expected.
    below code has been adjusted:
    buttons: [{ text: 'Search', id: 'Search', listeners: {
    click: function () {
    var st = Ext.data.StoreManager.lookup('mystore');
    st.proxy.extraParams = { 'param1': 'test22', 'param2': 'test22' };
    st.load();
    }}}]

    Ext.Ajax.request({
    url: "Service2.asmx/GetPeople",
    method: 'GET'
    })

    read param value in webservice:
    System.Web.HttpContext.Current.Request.Params["param1"].ToString();

  5. #5
    Sencha - Support Team
    Join Date
    Feb 2013
    Location
    California
    Posts
    4,065
    Vote Rating
    69
    Answers
    157
    Gary Schlosberg has a spectacular aura about Gary Schlosberg has a spectacular aura about Gary Schlosberg has a spectacular aura about

      0  

    Default


    Glad you figured it out, and thanks for sharing the solution with the community.

  6. #6
    Sencha User
    Join Date
    Sep 2013
    Posts
    6
    Vote Rating
    0
    kvbhaskar.net@gmail.com is on a distinguished road

      0  

    Default


    Hi,
    I have some issue with pagination, basically my database has 30,000+ rows so trying to load data using remote pagination features and my page size is 25. I can't return all rows from my database because response data going to be huge and nothing will display on grid so retrieving 25 rows per page and implimented row number logic in sql that working as expected but on GUI total page count shows 1 and display message shows 1-25 of 25.

    I assume, my data the totalRecords may be wrong. can anyone suggest me?, appreciate if you post some example.

    In my store:
    reader: new Ext.data.JsonReader({ root: 'd', totalProperty: 'totalRecords', idProperty: 'SEQ_NO' })

    In Grid Panel:
    remotePage: true,
    bbar: Ext.create('Ext.PagingToolbar', {
    store: store,
    displayInfo: true,
    displayMsg: 'Number of records {0} - {1} of {2}',
    emptyMsg: "No data available"

    }),

    Response from webservice:
    <?xml version="1.0" encoding="utf-8" ?>
    - <ArrayOfModel_Summary xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://tempuri.org/">
    - <Model_Summary>
    <SEQ_NO>121076</SEQ_NO>
    <c1>37419590</c1>
    <c2>JP3690400001</c2>
    <c3>5302.T</c3>
    <totalRecords>30000</totalRecords>
    </Model_Summary>


    webservice is serialized as:
    [ScriptMethod(ResponseFormat = ResponseFormat.Json, UseHttpGet = true, XmlSerializeString = false)]

    can anyone suggest me what I am doing wrong here?.