ASP.NET Podcast

ASP.NET Podcast is geared towards the Microsoft .NET Framework and ASP.NET.
The podcast is run by Wally McClure, David Penton, and Paul Glavich.
Welcome to ASP.NET Podcast Sign in | Join | Help
in Search

ASP.NET Podcast

The ASP.NET Podcast features, technical talks, interviews, news, reviews, and Wallyisms. Wallace B. (Wally) McClure, David Penton, and Paul Glavich are your hosts. We talk about ASP.NET, AJAX, Performance, Databases, WCF, Silverlight, Cloud Computing, Windows Azure, and whatever else we decide to talk about.

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

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

Published Friday, September 21, 2007 2:24 AM by admin
Filed under: , ,
Anonymous comments are disabled

This Blog

Syndication

Powered by Community Server, by Telligent Systems