0

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

2 Answers 2

1

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
    }
Sign up to request clarification or add additional context in comments.

Comments

0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.