Click here to Skip to main content
15,886,864 members
Articles / Web Development / ASP.NET

Client Templating with jQuery

Rate me:
Please Sign up or sign in to vote.
4.96/5 (60 votes)
15 Nov 2010CPOL6 min read 175.5K   1.8K   152  
This article discusses a very cool feature of jQuery that is Client Templating
using System;
using System.Web.Services;
using System.Collections.Generic;
using System.Web.Script.Serialization;


public partial class _Default : System.Web.UI.Page 
{
    protected void Page_Load(object sender, EventArgs e)
    {
       // hfPersonData.Value = GetPersons(string.Empty);
        
    }

    [WebMethod()]
    public static string GetPersons()
    {
        List<Person> persons = new List<Person>()
        {
            new Person { UId = 1, Name = "Brij", Address = "Noida"},
            new Person { UId = 2, Name = "Rahul", Address = "New Delhi" },
            new Person { UId = 3, Name = "John0", Address = "Chris"}
        };

        JavaScriptSerializer ser = new JavaScriptSerializer();
        // ser.Serialize(persons);
        return ser.Serialize(persons);

    }
    [WebMethod()]
    public static string AddPerson(string count)
    {
    
        List<Person> persons = new List<Person>()
        {
            new Person() { UId = Convert.ToInt32(count), Name = "New Name" + count, Address = "My New Address" + count }
        };

        JavaScriptSerializer ser = new JavaScriptSerializer();
        // ser.Serialize(persons);
        return ser.Serialize(persons);

    }

    

    public class Person
    {
        public int UId { get; set; }
        public string Name { get; set; }
        public string Address { get; set; }
    }
    
}


By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior)
India India
Brij is a 3-times Microsoft MVP in ASP.NET/IIS Category and a passionate .NET developer. More than 6 years of experience in IT field, currently serving a MNC as a Tech Lead/Architect.

He is a very passionate .NET developer and have expertise over Web technologies like ASP.NET 2.0/3.5/4.0, jQuery, JSON, Javascript, IIS and related technologies. He is also a Exchange Server (EWS) Specialist. He has great experience in design patterns and N-Tier Architecture.

He is also certified as Microsoft Certified Technologies Specialist-ASP.NET and Microsoft Certified Technologies Specialist-WCF in .NET 4.0. He has also received several awards at various forums and his various articles got listed as "Article of the day" at ASP.NET Microsoft Official Website www.asp.net.

He has done MCA from NIT Durgapur and completed his graduation from Lucknow University.

Learning new technologies and sharing knowledge excites him most. Blogging, solving problems at various forums, helping people, keeps him busy entire day.


Visit his Blog: Code Wala

Area of Expertise :
C#, ASP.NET 2.0,3.5,4.0, AJAX, JQuery, JSON, XML, XSLT, ADO.Net, WCF, Active Directory, Exchange Server 2007 (EWS), Java script, Web Services ,Win services, DotnetNuke, WSS 3.0,Sharepoint Designer, SQL Server 2000/2005/2008

Comments and Discussions