AJAX Web Development Using .Net 2.0

24
Building Effective Web Applications with ASP .Net 3.5 Noah Subrin SRA University Fall 2008 Week 2

Transcript of AJAX Web Development Using .Net 2.0

Page 1: AJAX Web Development Using .Net 2.0

Building Effective Web Applications with ASP .Net 3.5

Noah SubrinSRA UniversityFall 2008Week 2

Page 2: AJAX Web Development Using .Net 2.0

Today’s Agenda Student Q&A Week 1 Optional Homework Review Data Access Data bound controls DataSources LINQ to SQL

Page 3: AJAX Web Development Using .Net 2.0

Student Feedback\Q&A

Please feel free to post questions and discuss development questions on our class collaborative site on the SRA portal

1. Web.config files in multiple environments

2. Layout of controls on web forms3. JavaScript debugging4. Traditional .Net Framework

development vs. .Net MVC

Page 4: AJAX Web Development Using .Net 2.0

Optional Homework – Virtual Lab or VS2008 Training Kit

Also can be found as part of VS2008 Training Kit Lab “Building Web Applications with VS2008”

1. Use the CSS designer to create new styles

2. Create an image summary page using LINQ classes

3. Add ListView and DataPager controls and add paging

Page 5: AJAX Web Development Using .Net 2.0

Overview of Data Access (Chapter 8)

99.99% of apps involve some type of data

We can use data bound controls to generate our web application’s UI

SQL Server Express is a royalty free database included with VS2008 or Visual Web Developer.

Page 6: AJAX Web Development Using .Net 2.0

Types of Data bound Controls p337

Lists Tabular Hierarchical

Page 7: AJAX Web Development Using .Net 2.0

Bind Controls to a DataSource p350

SQLDataSource LinqDataSource AccessDataSource ObjectDataSource XmlDataSource SiteMapDataSource

Page 8: AJAX Web Development Using .Net 2.0

Data Driven App Demos

Code From Chapter 81. Add/Configure a SQLDataSource2. List Controls3. Tabular4. Hierarchical Data

This demo uses an xml file as a data source.

5. CRUD Sample – Employee Directory

Page 9: AJAX Web Development Using .Net 2.0

Break

We will look discuss LINQ after break

Page 10: AJAX Web Development Using .Net 2.0

What is LINQ? LINQ stands for Language

Integrated Query A general purpose query facility to

query relational data, XML data, objects/collections.

New in .Net Framework 3.5 – must target .Net Framework 3.5

Based on standard query operators LINQ query syntax resembles

backwards SQL statements

Page 11: AJAX Web Development Using .Net 2.0

LINQ Architecture

.NET Language Integrated QueryC# 3.0C# 3.0 VB 9.0VB 9.0 Others…Others…

LINQ toLINQ toObjectsObjects

LINQ toLINQ toSQLSQL

LINQ toLINQ toXMLXML

LINQ toLINQ toDataSetsDataSets

Objects

<book> <title/> <author/> <year/> <price/></book>

XMLRelational

Page 12: AJAX Web Development Using .Net 2.0

Benefits of Using LINQ May not need to build an entire DAL

(data access layer) Much easier to query XML – don’t

have to use Xpath Work with data in a consistent way –

whether it is SQL Server data, XML data, ADO .Net dataset, an object collection, or data in memory

Offers compile time checking, autocompletion, and Intellisense

Page 13: AJAX Web Development Using .Net 2.0

New C# Language Featuresthat Support LINQ p902

Automatic properties Initializers Type Inference Anonymous types

Page 14: AJAX Web Development Using .Net 2.0

Three Parts of a LINQ Query

Obtain the data source Create the query Execute the query

Page 15: AJAX Web Development Using .Net 2.0

What’s a DataContext?

The DataContext is the source of all entities mapped over a database connection

It tracks changes that you made to all retrieved entities and maintains an "identity cache" that guarantees that entities retrieved more than one time are represented by using the same object instance.

Page 16: AJAX Web Development Using .Net 2.0

LINQ Demos from MSDN Library Help Files

How to: Query an ArrayList with LINQ

LINQ to XML vs. DOM Paste as XML C# Addin

Page 17: AJAX Web Development Using .Net 2.0

C# Building the Paste Xelement as XML Addin

http://www.hanselman.com/blog/PasteXMLAsXLinqXElementVisualStudioAddIn.aspx

Page 18: AJAX Web Development Using .Net 2.0

Creating LINQ to SQL Entities

Building Entities with the Object Relational Designer p922

Using the LINQDataSource controlp926

Page 19: AJAX Web Development Using .Net 2.0

Other MVC Resources

MSDN Virtual Lab on Introduction to .Net MVC

Discussion of .Net MVC can be found on www.asp.net/mvc/

Book - Design Patterns by Gamma, Helm, Johnson, and Vlissides

Page 20: AJAX Web Development Using .Net 2.0

Other LINQ resources

www.thinqlinq.com Book – LINQ in Action Msdn.microsoft.com articles on LINQ

Page 21: AJAX Web Development Using .Net 2.0

More on JavaScript Debugging

Scott Guthrie’s bloghttp://weblogs.asp.net/scottgu/

archive/2007/07/19/vs-2008-javascript-debugging.aspx

Page 22: AJAX Web Development Using .Net 2.0

Optional Take Home Class Exercise

Do any one of the following:1. MSDN Virtual Lab “Using LINQ to SQL

with the .Net Framework 3.5 and Visual Studio 2008” Event ID: 1032376015(msevents.microsoft.com)

2. Download lab manual from #1, install Northwind database and do lab on your pc.

3. Do VS2008 Training Kit Lab “LinqToSql”

Page 23: AJAX Web Development Using .Net 2.0

Next Week

Week 2 Q&A Homework Review (Take home lab) Chapters 31-33 (AJAX)

Page 24: AJAX Web Development Using .Net 2.0

Questions ?

Feel free to contact me at [email protected]

Please use the class portal site on the SRA portal to post question or other discussions that may be of interest to the class.

Thank you!