Accessing an ADO.NET Data Service with ASP.NET AJAX Part II

The best way to access an ADO.NET Data Service from an Ajax application is to use the ASP.NET AJAX 4 preview, which is available here.  The javascript files then need to be copied into your website, and referenced in your webpage.  I used the debug versions in this project.  Data from the Data Service can be displayed without writing a line of javascript.

SimpleDataDisplay

This about the simplest example of client-side templating.  Four additions have been made to a standard page of html.  First, the script tags on lines 6 to 8; second, the two xml namespaces and the sys:activate=”*” in the body tag on lines 10 to 12; third, the parameters in the tbody tag on lines 27 to 32; and fourth, the binding expressions within the td tags on lines 34 to 40.  For your own project, the Mix.svc on line 29 must be replaced with the name of your own service.  “Presenters” on line 30 must be replaced with the name of the table you wish to display on the client.  On line 31, $top is one of several possible fetchparameters.  This one tells the Data Service how many records to return.  On lines 34 to 40, the words following each binding correspond to the names of the database fields that will be displayed.  This code, together with a stylesheet, produces the following result:

FirstTable

The styling for the table is based on a gridview on Matt Berseth’s website.  To avoid adding to the markup, I omitted the rounded corners.

In my next few posts, I will extend this example.

Advertisements

One Response to “Accessing an ADO.NET Data Service with ASP.NET AJAX Part II”

  1. Summaries 15.04.2009 « Bogdan Brinzarea’s blog Says:

    […] Accessing an ADO.NET Data Service with ASP.NET AJAX (Part 2) […]


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: