Skip to main content

Microsoft Ajax Client Template

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
<head runat="server">
    <title>Ajax Client Side Template</title>

    <script src="Scripts/MicrosoftAjax.debug.js" type="text/javascript"></script>

    <script src="Scripts/MicrosoftAjaxTemplates.debug.js" type="text/javascript"></script>

    <script src="Scripts/MicrosoftAjaxAdoNet.debug.js" type="text/javascript"></script>

    <style type="text/css">
            display: none;

    <script type="text/javascript">
        function LoadData() {
            $create(Sys.UI.DataView, {
                dataProvider: "Service.svc",
                fetchOperation: "GetData",
                autoFetch: "true"
            }, {}, {}, $get("tblProduct"));

    <form id="form1" runat="server">
    <input type="button" id="btnFetch" value="Display Data" onclick="LoadData();" />
    <table id="tblProduct" class="sys-template" border="1">
using System;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Activation;
using System.ServiceModel.Web;
using System.Collections.Generic;
public class Product
    public string ProductName;
    public int ProductID;
[ServiceContract(Namespace = "")]
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class Service
    // Add [WebGet] attribute to use HTTP GET
    public List<Product> GetData()
        List<Product> ret = new List<Product>();

        for (int i = 0; i < 10; i++)
            ret.Add(new Product {ProductName = "Product " + i.ToString(), ProductID = i });
        return ret;



Popular posts from this blog