Skip to main content

Posts

Showing posts from February, 2012

Asp.net mvc using JsonResult

Json has become one of the most popular form of data interchange method and being tightly integrated in the mvc framework makes it very easy to use. I will be demonstratating a very usefull technique of passing a response in an Ajax style using JsonResult (It is a class that is used in mvc framework to pass a json formatted content to the response). Model public class Users { public int UserId { get; set; } public string UserName { get; set; } } Controller public ActionResult Index() { return View(); } public JsonResult GetUsers() { List<Users> users = new List<Users>() { new Users { UserId =1, UserName ="kaunain" }}; return this.Json(users,JsonRequestBehavior.AllowGet); } View <script type="text/javascript" language="javascript"...