Recent Posts

Wednesday, August 13, 2008

Ajax like look and feel from Json and what is Json?

JSON what is it and how it works?

The description of JSON is "JavaScript Object notation".
According to the official website it is a lightweight data-interchange
format. It is human readable and writeable and is a subset of the Javascript
Programming Language.
It is completely language independent.
Jason Looks like this and is in easily readable format like xml.

"Firstname": "John",
"Lastname": "Smith",
"emailaddrs": [
{"type": "work", "value": ""},
{"type": "home", "pref": 1, "value": ""}
"phones": [
{"type": "work", "pref": 1, "value": "123 12321221321"},
{"type": "mobile", "value": "123 23232323"}
["2006", "2007", "2008"]


You can access the jason property in javaScript as follows:

var fname = jsonObject.FirstName

I found this help from and I have tried this out myself and found this to be interesting topic to be explored.

Also while trying this I have a test project that i will explain it to you guys that helps you to understand about it more.

This example shows how easy it is to build dynamic lists using jason and and having the ajax experience in

1. First step is to download the following dlls from Download Jason Dlls

2. Open a web project and put those two dlls in the bin folder of your project.

3. add a web form and name it rprateekDemo.aspx and copy the following code :
(or you can add any name and modify code as per the name of the aspx)

(note: you can get the source file on the JasonDll.rar that you downloaded above

4. Then add the following code in the code behind file rprateeDemo.aspx.cs :

using System;

namespace rprateek.blogspot
public partial class SimpleListDemoPage : System.Web.UI.Page
protected void Page_Load(object sender, EventArgs e)
if (!IsPostBack)
TagList.Model["tags"] = new string[] { "AjaxFeel", "MVC", "JavaScript" };

protected void SubmitButton_Click(object sender, EventArgs e)
// Retrieve updated data model from control
string[] tags = (string[])TagList.Model["tags"];
ResultsLabel.Text = string.Format("You entered {0} tag(s): {1}", tags.Length, string.Join(", ", tags));

5. Add a file name it TagList.jmvc and copy the following code in the file :

(note: you can get the source file on the JasonDll.rar that you downloaded above )

6. Now save build and run the application and check out how sweetly it works.

Related Posts by Categories

No comments:

Post a Comment