Follow me on Twitter at Twitter.com/wbm
FYI, I'm blogging most of my stuff over at More Wally now.
You might want to add my rss feed to your reader at:http://morewally.com/cs/blogs/wallym/rss.aspx
September 2007 - Posts - Wallace B. McClure

Wallace B. McClure

All About Wally McClure - The musings of Wallym on Web, HTML5, Mobile, Xamarin.iOS, Xamarin.Android, and Windows Azure.

News

Visual Studio Magazine Column Personal Blog

.NET

Book Authors

Business

Family

Friends

Georgia Tech Bloggers

Personal

Archives

September 2007 - Posts

ASP.NET Podcast Show #101 - ASP.NET AJAX Futures Data - Video and Audio

Subscribe <-- What everyone should be doing.

Download WMV <-- The old style way of doing it.

Download MP4 for Ipod and Zune <-- ditto

Download MP3 <-- ditto

Original url: http://aspnetpodcast.com/CS11/blogs/asp.net_podcast/archive/2007/09/21/asp-net-podcast-show-101-asp-net-ajax-futures-data.aspx

Show Notes:

Web.config additions:

<system.web.extensions>

<scripting>

<webServices>

<jsonSerialization>

<converters>

<add name="DataSetConverter" type="Microsoft.Web.Preview.Script.Serialization.Converters.DataSetConverter, Microsoft.Web.Preview"/>

<add name="DataRowConverter" type="Microsoft.Web.Preview.Script.Serialization.Converters.DataRowConverter, Microsoft.Web.Preview"/> <add name="DataTableConverter" type="Microsoft.Web.Preview.Script.Serialization.Converters.DataTableConverter, Microsoft.Web.Preview"/>

</converters>

Web Service Code

using System;

using System.Collections;

using System.ComponentModel;

using System.Data;

using System.Linq;

using System.Web;

using System.Web.Script.Services;

using System.Web.Services;

using System.Web.Services.Protocols;

using System.Xml.Linq;

using Microsoft.Web.Preview.Services;

/// <summary>

/// Summary description for WebService

/// </summary>

[WebService(Namespace = "http://tempuri.org/")]

[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]

// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.

[ScriptService]

public class WebService : DataService

{

public WebService()

{

//Uncomment the following line if using designed components

//InitializeComponent();

}

[
WebMethod]public string HelloWorld()

{

return "Hello World";

}

[WebMethod]

[DataObjectMethod(DataObjectMethodType.Select)]public DataSet GetValues(int i)

{

DataSet ds = new DataSet();

DataTable dt = new DataTable();

DataRow dr;

dt.Columns.Add(new DataColumn("Name"));dt.Columns.Add(new DataColumn("ID", Type.GetType("System.Int32")));

dr = dt.NewRow();

if (i % 2 == 0)

{

dr["Name"] = "Wally McClure";

dr["ID"] = 1;

}

else

{

dr[
"Name"] = "Paul Glavich";dr["ID"] = 2;

}

dt.Rows.Add(dr);

ds.Tables.Add(dt);

return (ds);

}

}

JavaScript code:

function pageLoad() {

WebService.GetValues(1, OnCompletion);

}

function OnCompletion(results)

{

var dataOutput = "";

var divOutput = $get("Output");

var strReturn = "<br />";

dataOutput = "Dataset: " + strReturn;

for(m in results)

{

dataOutput += m + strReturn;

}

dataOutput += "DataTable: " + strReturn;

for(m in results.tables[0])

{

dataOutput += m + strReturn;

}

dataOutput += "Rows: " + strReturn;

for(m in results.tables[0].rows)

{

dataOutput += m + strReturn;

}

dataOutput += "Rows[0]: " + strReturn;

for(m in results.tables[0].rows[0])

{

dataOutput += m + strReturn;

}

dataOutput += "Rows[0].Name: " + strReturn;

for(m in results.tables[0].rows[0].Name)

{

dataOutput += m + strReturn;

}

dataOutput += "Columns: " + strReturn;

for(m in results.tables[0].columns)

{

dataOutput += m + strReturn;

}

dataOutput += "Columns[0]: " + strReturn;

for(m in results.tables[0].columns[0])

{

dataOutput += m + strReturn;

}

dataOutput +=
"rows[0].Name: " + results.tables[0].rows[0].Name + strReturn;

dataOutput += "Columns[0].dataType: " + results.tables[0].columns[0].dataType + strReturn;

dataOutput += "Columns[1].dataType: " + results.tables[0].columns[1].dataType + strReturn;

dataOutput += "Columns[1].isKey: " + results.tables[0].columns[1].isKey + strReturn;

divOutput.innerHTML = dataOutput;

}

ASP.NET AJAX Futures Data

More Posts