Tuesday, June 3, 2008

ASP.NET 3.5 Features

Integrated ASP.NET AJAX support

ListView control - ListView is update to DataList and Repeater controls

DataPager control - Free standing paging Interface. It renders a paging interface with Next Previous first last buttons and is tied to a data web control.
It works only with web controls that implements IPageableItemContainer interface, which currently includes only ListView control

3.5 framework has LINQ - Language Integrated Query.

LINQ makes SQl Like syntax allowing developers to work work with data.
Ex:

List<string> ProductNames = from p in products
where p.productid = 1
select p.productname

LINQ statements operate on Database , XML or an Object Layer.
VS 2008 gives Intellisense support to LINQ Syntax

VS 2008 New Features

Visual Studio 2008 is Multi Targeted. That is, we can choose which framework to work on from a dropdownlist. (2.0, 3.0, 3.5).
That is with 2008 we can start working 2.0 also.

Improved Designer experience - Split Screen feature
If some control is dropped on to the page source view automatically gets changed.
But the reverse is not true. You have to save page or click on refresh in designer.

Javascript Debugging
Itellisense features
Advanced CSS editing options

Programming Practices

Refactor Large methods.
Do not share Member variables.
Use Try Catch and Finally block.
Close objects once its work is over.
Open database connection just before executing query and close in finally block.
Create Business Objects.
Sepearte Presentation, Business Logic and Data Access layers.
Do not send database objects to presentation layer.
Use Generics.
Catch exceptions, give proper message to user and store info in log file.
Store ConnectionString in Web.Config file encrypted
Use Page.IsValid before submitting your page when you are using Server side validation controls
when any browser doesnt support javascript, Page.IsValid avoids submitting data
Use StringBuilder than String

Use Custom Base Page class when there is a need to change some value for all pages
Do not forget to change Debug property to False before Deploying application into production
Always use dataReaders with "using" like
Using (SQLdataReader dr = cmd.ExecuteReader())
{
While(dr.read())
{
Response.Write(dr.GetString(0));
}
}

Use dataReader when datspeed is a concern
Whenever data is retrieved from database to a variable check for null
Use ObjectDataSource than SQLdataSource
Use CSS instead of formatting controls in page itself
If page is CrossPosted check if PreviousPage != null
If you want to resue inside a single project Web User Control is the fastest way.
Do not store heavy objects in ViewState

Speed Optimization

Paging - Do not use User Interface Paging. Use ObjectDataSource's CanPage property.
Turn off session state where it is not used - <%@ Page EnableSessionState="False" %>
Viewstate can be turned off when not required .

Use Caching
Use SqlDataReaders
Use Stored Procedures