Monday, December 22, 2008

my second windows form

Form1.Designer.cs

using System.Drawing;//
using System.Windows.Forms;//
using System;//
namespace MyPhoto
{
partial class Form1
{
///
/// Required designer variable.
///

private System.ComponentModel.IContainer components = null;

///
/// Clean up any resources being used.
///

/// true if managed resources should be disposed; otherwise, false.
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}

#region Windows Form Designer generated code

///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///

private void InitializeComponent()
{
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.loadToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
this.menuStrip1.SuspendLayout();
this.SuspendLayout();
//
// pictureBox1
//
this.pictureBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.pictureBox1.Location = new System.Drawing.Point(24, 29);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(234, 200);
this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
this.pictureBox1.TabIndex = 0;
this.pictureBox1.TabStop = false;
this.pictureBox1.Click += new System.EventHandler(this.pictureBox1_Click);
//
// menuStrip1
//
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.fileToolStripMenuItem});
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
this.menuStrip1.Name = "menuStrip1";
this.menuStrip1.Size = new System.Drawing.Size(284, 25);
this.menuStrip1.TabIndex = 1;
this.menuStrip1.Text = "menuStrip1";
//
// fileToolStripMenuItem
//
this.fileToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.loadToolStripMenuItem,
this.toolStripSeparator1,
this.exitToolStripMenuItem});
this.fileToolStripMenuItem.Name = "fileToolStripMenuItem";
this.fileToolStripMenuItem.Size = new System.Drawing.Size(39, 21);
this.fileToolStripMenuItem.Text = "&File";
//
// loadToolStripMenuItem
//
this.loadToolStripMenuItem.Name = "loadToolStripMenuItem";
this.loadToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.L)));
this.loadToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
this.loadToolStripMenuItem.Text = "&Load";
this.loadToolStripMenuItem.Click += new System.EventHandler(this.HandleLoadClick);
//
// toolStripSeparator1
//
this.toolStripSeparator1.Name = "toolStripSeparator1";
this.toolStripSeparator1.Size = new System.Drawing.Size(149, 6);
//
// exitToolStripMenuItem
//
this.exitToolStripMenuItem.Name = "exitToolStripMenuItem";
this.exitToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
this.exitToolStripMenuItem.Text = "E&xit";
this.exitToolStripMenuItem.Click += new System.EventHandler(this.exitToolStripMenuItem_Click);
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(284, 264);
this.Controls.Add(this.pictureBox1);
this.Controls.Add(this.menuStrip1);
this.MainMenuStrip = this.menuStrip1;
this.Name = "Form1";
this.Text = "hello Form1";
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
this.menuStrip1.ResumeLayout(false);
this.menuStrip1.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();

}

#endregion

private void HandleLoadClick(object sender, System.EventArgs e)
{
OpenFileDialog dlg = new OpenFileDialog();
dlg.Title = "Open Photo";
dlg.Filter = "jpg files(*.jpg)|*.jpg|All files(*.*)|*.*";

if (dlg.ShowDialog() == DialogResult.OK)
{
try
{
pictureBox1.Image = new Bitmap(dlg.OpenFile());
}
catch (ArgumentException ex)
{
MessageBox.Show("Unable to upload the file: "+ex.Message);
}
}
dlg.Dispose();
}

private System.Windows.Forms.PictureBox pictureBox1;
private MenuStrip menuStrip1;
private ToolStripMenuItem fileToolStripMenuItem;
private ToolStripMenuItem loadToolStripMenuItem;
private ToolStripSeparator toolStripSeparator1;
private ToolStripMenuItem exitToolStripMenuItem;
}
}

my first windows form

Form1.Designer.cs

using System.Windows.Forms;
using System.Drawing;
namespace MyForm
{
partial class Form1
{
///
/// Required designer variable.
///

private System.ComponentModel.IContainer components = null;

///
/// Clean up any resources being used.
///

/// true if managed resources should be disposed; otherwise, false.
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}

#region Windows Form Designer generated code

///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///

private void InitializeComponent()
{
this.button1 = new System.Windows.Forms.Button();
this.pictureBox1 = new System.Windows.Forms.PictureBox();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
this.SuspendLayout();
//
// button1
//
this.button1.Location = new System.Drawing.Point(54, 28);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 23);
this.button1.TabIndex = 0;
this.button1.Text = "Load";
this.button1.UseVisualStyleBackColor = true;
this.button1.Left = 10;
this.button1.Top = 10;
this.button1.Click += new System.EventHandler(this.HandleLoadClick);
this.button1.Anchor = AnchorStyles.Top | AnchorStyles.Left;
//
// pictureBox1
//
this.pictureBox1.Location = new System.Drawing.Point(54, 85);
this.pictureBox1.Name = "pictureBox1";
//this.pictureBox1.Size = new System.Drawing.Size(179, 119);
this.pictureBox1.TabIndex = 1;
this.pictureBox1.TabStop = false;
this.pictureBox1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.pictureBox1.Width = this.Width / 2;
this.pictureBox1.Height = this.Height / 2;
pictureBox1.Left = (this.Width - pictureBox1.Width) / 2;
pictureBox1.Top = (this.Height - pictureBox1.Height) / 2;
this.pictureBox1.SizeMode = PictureBoxSizeMode.Zoom;
this.pictureBox1.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;

//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(476, 327);
this.Controls.Add(this.pictureBox1);
this.Controls.Add(this.button1);
this.Name = "Form1";
this.Text = "Hello Form";
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
this.ResumeLayout(false);

}

#endregion

private void HandleLoadClick(object sender,System.EventArgs e)
{
OpenFileDialog dlg = new OpenFileDialog();
dlg.Title = "Open Photo";
dlg.Filter = "jpg files(*.jpg)|*.jpg|All files(*.*)|*.*";

if (dlg.ShowDialog() == DialogResult.OK)
{
pictureBox1.Image = new Bitmap(dlg.OpenFile());
}
dlg.Dispose();
}

private System.Windows.Forms.Button button1;
private System.Windows.Forms.PictureBox pictureBox1;

}
}

Form1.cs

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace MyForm
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
}
}

Program.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;

namespace MyForm
{
static class Program
{
///
/// The main entry point for the application.
///

[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
}

Wednesday, December 3, 2008

用javascript 返回上一级页面

<input id="Button1" type="button" value="button" onclick="javascript:history.go(-1);" />

用这个onclick="javascript:history.go(-1);"方法可以实现页面返回功能,而且父页面保持原状态(即跳转到子页面之前的状态)。

鼠标悬停在控件上时候出现气泡提示语

<asp:TextBox ID="TextBox1" runat="server" title="请输入用户名"></asp:TextBox>
<asp:Button ID="Button1" runat="server" Text="Button" title="请输入用户名" />

Tuesday, December 2, 2008

C#文件读写常用类介绍(转载)

C#文件读写常用类介绍
Source:http://www.sz-accp.com.cn/xxyd/ShowArticle.asp?ArticleID=625,
首先要熟悉.NET中处理文件和文件夹的操作。File类和Directory类是其中最主要的两个类。了解它们将对后面功能的实现提供很大的便利。
  本节先对和文件系统相关的两个.NET类进行简要介绍。
  System.IO.File类和System.IO.FileInfo类主要提供有关文件的各种操作,在使用时需要引用System.IO命名空间。下面通过程序实例来介绍其主要属性和方法。
  (1) 文件打开方法:File.Open ()
  该方法的声明如下:
public static FileStream Open(string path,FileMode mode)
  下面的代码打开存放在c:\tempuploads目录下名称为newFile.txt文件,并在该文件中写入hello。
private void OpenFile()
{
 FileStream.TextFile=File.Open(@"c:\tempuploads\newFile.txt",FileMode.Append);
 byte [] Info = {(byte)'h',(byte)'e',(byte)'l',(byte)'l',(byte)'o'};
 TextFile.Write(Info,0,Info.Length);
 TextFile.Close();
}
protected void myOpenFile(string msg)
{
StreamWriter sw = new StreamWriter(@"H:\SampleCode\ReadAndWriteFile\NewFile\SampleFile.txt");

sw.WriteLine(msg);
sw.Close();
}
  (2) 文件创建方法:File.Create()
  该方法的声明如下:
public static FileStream Create(string path;)
  下面的代码演示如何在c:\tempuploads下创建名为newFile.txt的文件。
  由于File.Create方法默认向所有用户授予对新文件的完全读/写访问权限,所以文件是用读/写访问权限打开的,必须关闭后才能由其他应用程序打开。为此,所以需要使用FileStream类的Close方法将所创建的文件关闭。
private void MakeFile()
{  
FileStream NewText=File.Create(@"c:\tempuploads\newFile.txt");
 NewText.Close();
} 
(3) 文件删除方法:File.Delete()
  该方法声明如下:
public static void Delete(string path);
  下面的代码演示如何删除c:\tempuploads目录下的newFile.txt文件。
private void DeleteFile()
{
 File.Delete(@"c:\tempuploads\newFile.txt");
}
  (4) 文件复制方法:File.Copy

  该方法声明如下:

public static void Copy(string sourceFileName,string destFileName,bool overwrite);
  下面的代码将c:\tempuploads\newFile.txt复制到c:\tempuploads\BackUp.txt。
  由于Cope方法的OverWrite参数设为true,所以如果BackUp.txt文件已存在的话,将会被复制过去的文件所覆盖。
private void CopyFile()
{
 File.Copy(@"c:\tempuploads\newFile.txt",@"c:\tempuploads\BackUp.txt",true);
}
  (5) 文件移动方法:File.Move
  该方法声明如下:
public static void Move(string sourceFileName,string destFileName);
  下面的代码可以将c:\tempuploads下的BackUp.txt文件移动到c盘根目录下。
  注意:
  只能在同一个逻辑盘下进行文件转移。如果试图将c盘下的文件转移到d盘,将发生错误。
private void MoveFile()
{
 File.Move(@"c:\tempuploads\BackUp.txt",@"c:\BackUp.txt");
}
 (6) 设置文件属性方法:File.SetAttributes
  该方法声明如下:
public static void SetAttributes(string path,FileAttributes fileAttributes);
  下面的代码可以设置文件c:\tempuploads\newFile.txt的属性为只读、隐藏。
private void SetFile()
{
 File.SetAttributes(@"c:\tempuploads\newFile.txt",
 FileAttributes.ReadOnly|FileAttributes.Hidden);
}
  文件除了常用的只读和隐藏属性外,还有Archive(文件存档状态),System(系统文件),Temporary(临时文件)等。关于文件属性的详细情况请参看MSDN中FileAttributes的描述。
  (7) 判断文件是否存在的方法:File.Exist
  该方法声明如下:
public static bool Exists(string path);
  下面的代码判断是否存在c:\tempuploads\newFile.txt文件。若存在,先复制该文件,然后其删除,最后将复制的文件移动;若不存在,则先创建该文件,然后打开该文件并进行写入操作,最后将文件属性设为只读、隐藏。
if(File.Exists(@"c:\tempuploads\newFile.txt")) //判断文件是否存在
{
 CopyFile(); //复制文件
 DeleteFile(); //删除文件
 MoveFile(); //移动文件
}
else
{
 MakeFile(); //生成文件
 OpenFile(); //打开文件
 SetFile(); //设置文件属性
}
  此外,File类对于Text文本提供了更多的支持。
  · AppendText:将文本追加到现有文件
  · CreateText:为写入文本创建或打开新文件
  · OpenText:打开现有文本文件以进行读取
  但上述方法主要对UTF-8的编码文本进行操作,从而显得不够灵活。在这里推荐读者使用下面的代码对txt文件进行操作。
  · 对txt文件进行“读”操作,示例代码如下:
StreamReader TxtReader = new StreamReader(@"c:\tempuploads\newFile.txt",System.Text.Encoding.Default);
string FileContent;
FileContent = TxtReader.ReadEnd();
TxtReader.Close();
  · 对txt文件进行“写”操作,示例代码如下:
StreamWriter = new StreamWrite(@"c:\tempuploads\newFile.txt",System.Text.Encoding.Default);
string FileContent;
TxtWriter.Write(FileContent);
TxtWriter.Close();
  System.IO.Directory类和System.DirectoryInfo类
  主要提供关于目录的各种操作,使用时需要引用System.IO命名空间。下面通过程序实例来介绍其主要属性和方法。
  (1) 目录创建方法:Directory.CreateDirectory
  该方法声明如下:
public static DirectoryInfo CreateDirectory(string path);
  下面的代码演示在c:\tempuploads文件夹下创建名为NewDirectory的目录。
private void MakeDirectory()
{
 Directory.CreateDirectory(@"c:\tempuploads\NewDirectoty");
}
  (2) 目录属性设置方法:DirectoryInfo.Atttributes
  下面的代码设置c:\tempuploads\NewDirectory目录为只读、隐藏。与文件属性相同,目录属性也是使用FileAttributes来进行设置的。
private void SetDirectory()
{
 DirectoryInfo NewDirInfo = new DirectoryInfo(@"c:\tempuploads\NewDirectoty");
 NewDirInfo.Atttributes = FileAttributes.ReadOnly|FileAttributes.Hidden;
}
  (3) 目录删除方法:Directory.Delete
  该方法声明如下:
public static void Delete(string path,bool recursive);
  下面的代码可以将c:\tempuploads\BackUp目录删除。Delete方法的第二个参数为bool类型,它可以决定是否删除非空目录。如果该参数值为true,将删除整个目录,即使该目录下有文件或子目录;若为false,则仅当目录为空时才可删除。
private void DeleteDirectory()
{
 Directory.Delete(@"c:\tempuploads\BackUp",true);
}
  (4) 目录移动方法:Directory.Move
  该方法声明如下:
public static void Move(string sourceDirName,string destDirName);
  下面的代码将目录c:\tempuploads\NewDirectory移动到c:\tempuploads\BackUp。
private void MoveDirectory()
{
 File.Move(@"c:\tempuploads\NewDirectory",@"c:\tempuploads\BackUp");
}
  (5) 获取当前目录下的所有子目录方法:Directory.GetDirectories
  该方法声明如下:
public static string[] GetDirectories(string path;);
  下面的代码读出c:\tempuploads\目录下的所有子目录,并将其存储到字符串数组中。
private void GetDirectory()
{
 string [] Directorys;
 Directorys = Directory. GetDirectories (@"c:\tempuploads");
}
  (6) 获取当前目录下的所有文件方法:Directory.GetFiles
  该方法声明如下:
public static string[] GetFiles(string path;);
  下面的代码读出c:\tempuploads\目录下的所有文件,并将其存储到字符串数组中。
private void GetFile()
{
 string [] Files;
 Files = Directory. GetFiles (@"c:\tempuploads",);
}
  (7) 判断目录是否存在方法:Directory.Exist
  该方法声明如下:
public static bool Exists(
 string path;
);
  下面的代码判断是否存在c:\tempuploads\NewDirectory目录。若存在,先获取该目录下的子目录和文件,然后其移动,最后将移动后的目录删除。若不存在,则先创建该目录,然后将目录属性设为只读、隐藏
if(File.Exists(@"c:\tempuploads\NewDirectory")) //判断目录是否存在
{
 GetDirectory(); //获取子目录
 GetFile(); //获取文件
 MoveDirectory(); //移动目录
 DeleteDirectory(); //删除目录
}
else
{
 MakeDirectory(); //生成目录
 SetDirectory(); //设置目录属性
}
  注意:
  路径有3种方式,当前目录下的相对路径、当前工作盘的相对路径、绝对路径。以C:\Tmp\Book为例(假定当前工作目录为C:\Tmp)。“Book”,“\Tmp\Book”,“C:\Tmp\Book”都表示C:\Tmp\Book。
  另外,在C#中 “\”是特殊字符,要表示它的话需要使用“\\”。由于这种写法不方便,C#语言提供了@对其简化。只要在字符串前加上@即可直接使用“\”。所以上面的路径在C#中应该表示为“Book”,@“\Tmp\Book”,@“C:\Tmp\Book”。 

Create Navigation Application with WPF

Monday, December 1, 2008

关于GridView数据行的鼠标悬停高亮的问题

其实这个问题很简单,只要两行代码就可以解决。

private void DataGrid1_ItemDataBound(object sender, DataGridItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
e.Item.Attributes.Add("onmouseover", "c=this.style.backgroundColor;this.style.backgroundColor='#66CCFF'");
e.Item.Attributes.Add("onmouseout", "this.style.backgroundColor=c");
}
}

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes.Add("onmouseover", "currentcolor=this.style.backgroundColor;this.style.backgroundColor='#6699ff';");
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=currentcolor;");
}
}

using Ajax to work with GridView




http://www.asp.net/learn/3.5-videos/video-362.aspx

Visual Studio 2008 - New Features

Introduction
Visual Studio 2008 code name "Orcas" Beta 2 has just hit the road and, since it is Beta 2, this means Visual Studio 2008 is feature complete and is ready for RTM. Below, we would find a brief introduction of some of the new features introduced with VS 2008 and .NET 3.5 Beta 2.

A quick list of some of the new features are:

Multi-Targeting support
Web Designer and CSS support
ASP.NET AJAX and JavaScript support
Project Designer
Data
LINQ – Language Integrated Query



The features listed and explained in this paper are not complete and this document intends to give you a forehand to start off with VS 2008.

1. Multi-Targeting Support
Earlier, each Visual Studio release only supported a specific version of the .NET Framework. For example, VS 2003 only works with .NET 1.1, and VS 2005 only works with .NET 2.0.

One of the major changes with the VS 2008 release is to support what Microsoft calls "Multi-Targeting". This means that Visual Studio will now support targeting multiple versions of the .NET Framework, and developers will be able to take advantage of the new features that Visual Studio provides without having to migrate their existing projects and deployed applications to use a new version of the .NET Framework.

Now when we open an existing project or create a new one with VS 2008, we can pick which version of the .NET Framework to work with. The IDE will update its compilers and feature-set to match the chosen .NET Framework.

Features, controls, projects, item-templates, and references that do not work with the selected version of the Framework will be made unavailable or will be hidden.

Unfortunately, support has not been included to work with Framework versions 1.1 and earlier. The present release supports 2.0/3.0 and 3.5 .NET Frameworks.

Microsoft plans to continue multi-targeting support in all future releases of Visual Studio.

Creating a New Project with Visual Studio 2008 that Targets .NET 2.0 Framework Library
The screenshots below depict the creation of a new web application targeting .NET 2.0 Framework. Choose File->New Project. As we see in the snapshot below in the top-right of the new project dialog, there is now a dropdown that allows us to choose which versions of the .NET Framework we want to target when we create the new project. The templates available are filtered depending on the version of the Framework chosen from the dropdown:



Can I Upgrade an Existing Project to .NET 3.5?
When we open a solution created using an older version of Visual Studio and Framework, VS 2008 would ask if migration is required. If we opt to migrate, then a migration wizard would start. If we wish to upgrade our project to target a newer version of the Framework at a later point of time, we can pull up the project properties page and choose the Target Framework. The required assemblies are automatically referenced. The snapshot below shows the properties page with the option Target Framework marked.


2. Web Designer, Editing and CSS Support
One feature that web developers will discover with VS 2008 is its drastically improved HTML designer, and the extensive CSS support made available.

The snapshots below depict some of the new web designer features in-built into VS 2008.

Split View Editing
In addition to the existing views, Design view and Code view, VS 2008 brings along the Split view which allows us to view both the HTML source and the Design View at the same-time, and easily make changes in any of the views. As shown in the image below, as we select a tag in code view, the corresponding elements/controls are selected in design view.


CSS Style Manager
VS 2008 introduces a new tool inside the IDE called "Manage Styles". This shows all of the CSS style sheets for the page.

It can be used when we are in any of the views - design, code and split views. Manage Styles tool can be activated by choosing Format -> CSS Styles -> Manage Styles from the menu. A snapshot of the same would look like the following:


Create a new style using the new style dialog window as show in the snapshot below.


Now, the style manager would show .labelcaption style as well in the CSS styles list. However, if we observe that the body element has a circle around it but the .labelcaption does not have one, this is because the style is not in use yet.


We will not select all the labels below and apply our new style .labelcaption.


We can choose to modify the existing style through GUI using "Modify style..." menu option in the dropdown menu as shown above or choose to hand edit the code by choosing the option "Go To Code".

CSS Source View Intellisense
The designer is equipped with the ability to select an element or control in design-view, and graphically select a rule from the CSS list to apply to it.

We will also find when in source mode that we now have intellisense support for specifying CSS class rules. The CSS Intellisense is supported in both regular ASP.NET pages as well as when working with pages based on master pages.


Code Editing Enhancements
Below is a non-exhaustive list of a few new code editing improvements. There are many more about which I don't know yet.

Transparent Intellisense Mode
While using VS 2005/2003 we often find ourselves escaping out of intellisense in order to better see the code around, and then go back and complete what we were doing.

VS 2008 provides a new feature which allows us to quickly make the intellisense drop-down list semi-transparent. Just hold down the "Ctrl" key while the intellisense drop-down is visible and we will be able to switch it into a transparent mode that enables us to look at the code beneath without having to escape out of Intellisense. The screenshot below depicts the same.


Organize C# Using Statements
One of the small, but a nice new feature in VS 2008 is support for better organizing using statements in C#. We can now select a list of using statements, right-click, and then select the "Organize Usings" sub-menu. When we use this command the IDE will analyze what types are used in the code file, and will automatically remove those namespaces that are declared but not required. A small and handy feature for code refactoring.


3. ASP.NET AJAX and JavaScript Support
JavaScript Intellisense
One new feature that developers will find with VS 2008 is its built-in support for JavaScript Intellisense. This makes using JavaScript and building AJAX applications significantly easier. A double click on HTML control in design mode would automatically create a click event to the button and would create the basic skeleton of the JavaScript function. As we see in the depicted image below, JavaScript Intellisense is inbuilt now. Other JavaScript Intellisense features include Intellisense for external JavaScript libraries and adding Intellisense hints to JavaScript functions.


JavaScript Debugging
One new JavaScript feature in VS 2008 is the much-improved support for JavaScript debugging. This makes debugging AJAX applications significantly easier. JavaScript debugging was made available in VS 2005 itself. However, we had to run the web application first to set the breakpoint or use the "debugger" JavaScript statement.

VS 2008 makes this much better by adding new support that allows us to set client-side JavaScript breakpoints directly within your server-side .aspx and .master source files.

We can now set both client-side JavaScript breakpoints and VB/C# server-side breakpoints at the same time on the same page and use a single debugger to step through both the server-side and client-side code in a single debug session. This feature is extremely useful for AJAX applications. The breakpoints are fully supported in external JavaScript libraries as well.

4. Few Other Features and Enhancements
Below is a list of few other enhancements and new features included in Microsoft Visual Studio 2008.

Project Designer
Windows Presentation Foundation (WPF) applications have been added to Visual Studio 2008. There are four WPF project types:

WinFX Windows Application
WinFX Web Browser Application
WinFX Custom Control Library
WinFX Service Library
When a WPF project is loaded in the IDE, the user interface of the Project Designer pages lets us specify properties specific to WPF applications.

Data
Microsoft Visual Studio 2008 Beta 2 includes the following new features to incorporate data into applications:

The Object Relational Designer (O/R Designer) assists developers in creating and editing the objects (LINQ to SQL entities) that map between an application and a remote database
Hierarchical update capabilities in Dataset Designer, providing generated code that includes the save logic required to maintain referential integrity between related tables
Local database caching incorporates an SQL Server Compact 3.5 database into an application and configures it to periodically synchronize the data with a remote database on a server. Local database caching enables applications to reduce the number of round trips between the application and a database server
LINQ – Language Integrated Query
LINQ is a new feature in VS 2008 that broadens great querying capabilities into the language syntax. LINQ introduces patterns for querying and updating data. A set of new assemblies are provided that enable the use of LINQ with collections, SQL databases, and XML documents.

Visual Studio 2008 Debugger
The Visual Studio 2008 debugger has been enhanced with the following features:

Remote debugging support on Windows Vista
Improved support for debugging multithreaded applications
Debugging support for LINQ programming
Debugging support for Windows Communications Foundation
Support for script debugging, including client-side script files generated from server-side script now appear in Solution Explorer


Reporting
Visual Studio 2008 provides several new reporting features and improvements such as:

New Report Projects: Visual Studio 2008 includes two new project templates for creating reporting applications. When we create a new Reports Application project, Visual Studio provides a report (.rdlc) and a form with a ReportViewer control bound to the report.
Report Wizard: Visual Studio 2008 introduces a Report Wizard, which guides us through the steps to create a basic report. After we complete the wizard, we can enhance the report by using Report Designer.
Expression Editor Enhancement: The Expression Editor now provides expressions that we can use directly or customize as required.
PDF Compression: The ReportViewer controls can now compress reports that are rendered or exported to the PDF format.