tags:

views:

87

answers:

2

Hi

On view users page am showing list of users in the list, and i want to show recent users by selecting dropdown of (Recent Users) in the same page. now am using post action to get the values and bind the list its getting full page load but i want to use to Ajax with Jquery option to show the list of datas in the same view page any one please help me with the code

thanks in advance

A: 

Hi there.

Handy examples:

http://www.dev102.com/2008/04/30/call-aspnet-webmethod-from-jquery/ http://www.dexign.net/post/2008/07/16/jQuery-To-Call-ASPNET-Page-Methods-and-Web-Services.aspx

I will give you a small example for the steps that should be taken.

First in your page you will put the calling of the web method:

 var objectData;  //Some variable you feel with the retrieved data

//function that calls your web method to retrieve the needed data.
  getUsers: function() {    
   $.post("<%=ResolveUrl("~/GetUsers/")%>", //GetUsers is your web method
        {
           Date: '',           //Fill here parameters needed by your web method

        }, function(msg) {
                objectData = msg;                   

      });      
    }

Of course then you do with the data whatever you need to (Display, format etc.)

Then you have to write your web method. I am not going to write the method, just going to put an example.

    //Code - (example is given in C#)


    [System.Web.Services.WebMethod]
    [System.Web.Script.Services.ScriptMethod(ResponseFormat = System.Web.Script.Services.ResponseFormat.Json)]
            public string GetUsers(DateTime date) //date is the parameter you pass the web method with the json call
            {
    // Retrieve data

    return ""; //return the desired result
    }
Ekaterina
You might also want to check this out too:http://marcgravell.blogspot.com/
Ekaterina
A: 

jqGrid and asp.net MVC play well together. You might want to look at Mr. Haack's blog:here

Paddy