44
Development in ASP.NET WebForms, LINQ, Dynamic Data Tanzim Saqib www.TanzimSaqib.com SaaS Developer Software as-a Service (SaaS) Platform British Telecom

Development In ASP.NET by Tanzim Saqib

Embed Size (px)

DESCRIPTION

Tanzim Saqib presents on development tools, and features for ASP.NET developers.

Citation preview

  • 1.Development in ASP.NETWebForms, LINQ, Dynamic Data
    TanzimSaqib
    www.TanzimSaqib.com
    SaaS Developer
    Software as-a Service (SaaS) Platform
    British Telecom

2. Session Summary
WebForms
LINQ
Dynamic Data
Futures ASP.NET 4
3. What is ASP.NET
Technology for web application development
Provides you with rich APIs and services
Robust, scalable, fast development experience
Great flexibility, less coding
Seamless integration with Microsoft stack tools
Not an upgrade from ASP
the next generation ASP
4. WebForms
UI elements that make up the Look & Feel of your application
Also known as just Page.
Code behind brings UI and code separation
Default.aspx
Default.aspx.cs
Advanced features reduce code
i.e. Data binding
Rich Drag & Drop design experience
5. WebForms (contd.)
Support for multiple languages
C#, VB, C++ and so on
Similar to Windows Forms programming model
Events, Properties, Methods
Extensibility
Third party assemblies and controls
runat=server
Compiled at server-side
Accessible by server code
6. ASP.NET Controls or Web Controls
7. Most Commonly Used WebControls
8. ASP.NET Ecosystem
9. Page Life Cycle Events
Events in green are the most frequently used
10. Page Life Cycle Events (contd.)
For more information: http://bit.ly/aspnetevents
11. WebForms Feature Highlights
Themes and skins
Master pages
Membership, Profile and Role Manager API
Application Services for AJAX applications
Website administration
Wide range choices for caching
Levels: Application, Session, Cache, Cookie, Page, Portion of Page
Handling errors
12. WebForms Feature Highlights (contd.)
ViewState
Technique to persist changes to state of a WebForm across postbacks
Stores in a hidden input field __VIEWSTATE
Encrypted
Increase length of the page, hence slows down
You can turn on/off
13. Cozying up with ASP.NET Development
demo
Building a complete data driven site
14. Groundbreaking innovation
LINQ
Language INtegrated Query
15. Language INtegrated Query - LINQ
Pronouced as Link
A language construct
Strongly typed query against objects
Full intellisense support
Can be used with any collection of objects that implements IEnumerable
Highly extensible
LINQ to XML
LINQ to SQL
LINQ to Flickr! etc.
16. LINQ Benefits
Simply put - avoiding having to learn and master many different domain languages, development or debugging environments in order to retrieve and manipulate data from different sources
One language to query all.
Deferred Execution
Process queries only when foreach/ToList() is being called.
Parallel Extensions help LINQ queries run in multiple processor cores in ASP.NET 4
17. Querying objects
demo
18. Obtaining data source
Query Expression Syntax:
varallProducts = from p in products select p;
Extension Method:
No representation. productsis the collection of objects
19. Filtering
Query Expression Syntax:
varlowOnProducts = from p in products
where p.UnitsInStock < 10 select p;
Extension Method:
products.Where(p => p.UnitsInStock < 10);
20. Ordering
Query Expression Syntax:
varlowOnProducts = from p in products
where p.UnitsInStock < 10
orderbyp.Name ascending
select p;
Extension Method:
products.Where(p => p.UnitsInStock < 10)
.OrderBy(p => p.Name);
21. Ordering (contd.)
Other helpful Extension Methods:
OrderBy
OrderByDescending
ThenBy
ThenByDescending
22. Grouping
string[] partNumbers = new string[] { "SCW10", "SCW1", "SCW2", "SCW11", "NUT10", "NUT1", "NUT2"};
Query Expression Syntax:
var query = from pN in partNumbers
group pN by pN.Substring(0,3);
Extension Method:
var query = partNumbers
.GroupBy(pN => pN.Substring(0,3));
foreach (var group in q) {
Console.WriteLine("Group key: {0}", group.Key);
foreach (var part in group) {
Console.WriteLine(" - {0}", part);
}
}
varlowOnProducts = from p in products
where p.UnitsInStock < 10
orderbyp.Name ascending
select p;
products.Where(p => p.UnitsInStock < 10)
.OrderBy(p => p.Name);
23. Grouping (contd.)
Iterating through grouped data:
foreach (var group in query) {
Console.WriteLine("Group key: {0}", group.Key);
foreach (var part in group) {
Console.WriteLine(" - {0}", part);
}
}
24. Standard Query Operators
25. Standard Query Operators (contd.)
26. Querying and modifying data
demo
LINQ DataContext
27. LINQ Query Provider
Roll your own provider:
YouTubeContextcontext = new YouTubeContext();
var query = (from v in context.Videos
where v.Location == " Moghbazar " && v.SearchText == Rail Crash"
select v).IfNotViewedBy(TanzimSaqib);
Building LINQ Provider series: http://bit.ly/LINQSeries
28. Life easier with
Dynamic Data
29. Dynamic Data Overview
Build powerful data driven sites in a minute!
Automatic creation of
WebForms
Controls and data binding
Validation logic in place
Metadata inferred from schema
Easy and highly customizable
Time saver and reusable
30. Building a website in less than a minute!
demo
31. Field Templates
Fields are User Controls
Dynamically chosen by datatype
Responsible for
Data binding
Validation and
Rendering
Reusable
32. Customizing Fields
demo
33. Customizing Pages
Page Templates
Changes affect all pages
Custom pages for individual tables
Custom columns and rendering
34. Customizing Pages
demo
35. Routing
Standard URL:
http://yourcompany.com/Products/Edit.aspx
Extensionless clean URL:
http://yourcompany.com/Products/Edit
No necessity to move files around
Routing engine is being used by
Dynamic Data
ASP.NET MVC
Attend the next session for deep dive into Routing and ASP.NET MVC
36. Routing
demo
37. Future is now
ASP.NET 4
Beta 1
38. Futures - ASP.NET 4
Support for meta tags
Page.Keywords, Page.Description
Enabling ViewState for individual controls
ViewStateMode property of the control
Reading route values at Page level:
Page.RouteData.Values[param_name_here"]
Reading route values from markup:

More precise and predictable ClientIDs
39. Futures - ASP.NET 4 (contd.)
QueryExtender
New server control
Works with LinqDataSource and EntityDataSource
More control over what is coming from Database
Controls for nested use with QueryExtender
SearchExpression
RangeExpression
PropertyExpression
CustomExpression
40. Futures - ASP.NET 4 (contd.)
Web.config transformation:
Development settings: web.debug.config
Production settings: web.release.config
Dynamic Data
New field template for URL, Email addresses
Client Template and Live data binding
Enables binding data source to HTML elements
Implemented with Observer pattern
Data changes from/to UI to/from Database notified
41. Futures - ASP.NET 4 (contd.)
Example

vardataContext = new Sys.Data.DataContext();
dataContext.set_serviceUri("emplyeeService.svc");
dataContext.initialize();



{bindingName}
{bindingAddress}



42. Futures - ASP.NET 4 (contd.)
Many more. For more information: http://bit.ly/aspnet4
43. Links and downloads: http://www.TanzimSaqib.com
Q & A
44. Thank you