240 likes | 1.42k Views
What’s New in Visual Studio.NET 2005. Andy Beaulieu MCT, MCSD.NET http://andy.beaulieu.com. Overview. VS.NET 2005 now scheduled to ship week of November 7 th 2005 VS.NET 2005 Supports Development of: .NET Framework 2.0 (ASP.NET, WindowsForms)
E N D
What’s New inVisual Studio.NET 2005 Andy Beaulieu MCT, MCSD.NET http://andy.beaulieu.com
Overview • VS.NET 2005 now scheduled to ship week of November 7th 2005 • VS.NET 2005 Supports Development of: • .NET Framework 2.0 (ASP.NET, WindowsForms) • .NET Compact Framework 2.0 (Pocket PC, Smartphone) • SQL Server 2005 (new template type creates in-process assembly for use from SQL 2005) • .NET 2.0 Contains Major improvements to: • ADO.NET • System.XML • WindowsForms • ASP.NET
Some of the Productivity Enhancements: • Smart Tags allow access to common properties/wizards • Edit Marks • show recent edits on a file • Yellow for unsaved • Green for saved • Code Snippets • Can be used to insert commonly used code • Called "Code Expansions" in C# • You can create your own using an XML file format and share • Debug/Watch Window • IntelliSense added • Data Visualizer shows DataSets • VB.NET only enhancements • "Edit and Continue" is back • "My" Namespace • C# only enhancements • Code Refactoring
Generics • Think of Generics as “classes that are parameterized by type” • When you create a class based on Generics, you specify a type, and from that point on the class is “locked into” that type. Public Class GenericList(Of ItemType) Inherits CollectionBase Public Function Add(ByVal value As ItemType) _ As Integer Return List.Add(value) End Function Public Sub Remove(ByVal value As ItemType) List.Remove(value) End Sub Public ReadOnly Property Item( _ ByVal index As Integer) As ItemType Get ' The appropriate item is retrieved from ' the List object and explicitly cast to ' the appropriate type, and then returned. Return CType(List.Item(index), ItemType) End Get End Property End Class
Generics • Solve problem of “loosely typed” collections • For Example, in .NET 1.x if you create a Collection or ArrayList, each element is of type “Object” • Nothing prevents programmer of inserting incompatible types into collection • Generic Collections available in .NET 2.0 • List–A basic collection • Dictionary–A name-value collection that indexes each item with a key. • LinkedList–A linked list, where each item points to the next item in the chain. • Queue–A first-in-first-out collection. • Stack–A last-in-first-out collection. • ReadOnlyCollection–A collection with a fixed set of items that can't be changed once it's created. • SortedDictionary–A name-value collection that's kept in perpetually sorted order.
DEMO: Generics Collection class in .NET 1.1 versus Generics in .NET 2.0
New ASP.NET Data Source Controls include... SQLDataSource Control • Database agnostic component used to bind UI controls to data from a DB such as SQL Server, Oracle, OLE-DB or ODBC Data Sources. • ObjectDataSource Control • Used to bind UI controls to Middle-tier Business Logic Components (next presentation deals with this)
DEMO: Using the SQLDataSource Control on a web pagewith GridView • Create a new Web Form • Drag/Drop the Northwind Customers table onto the page • A SQLDataSource control is automatically created • A GridView control is automatically created • Use the GridView SmartTag to allow sorting and paging, format
Support for “Data Access Layer” Components • Use in N-Tier environments to separate • User Interface • Business Logic • Data Access Layers • TableAdapter is a new component that works with Typed DataSet • Has Connection and Command objects to retrieve/update DB Entities • Data Access Component generation frees developer from monotonous ADO.NET code
Demo: Creating a Data Access Layer Component • Add a new DAL Class Project • Add a DataSet to the project called DSProducts • Add a TableAdapter to the DataSet • Enter the Query • In Beta 2 you must uncheck Optimistic Concurrency/Refresh the DataSet • Show the TableAdapter Configuration Wizard • Show the TableAdapter Query Configuration Wizard • Show how to add custom queries to TableAdapter
Demo: Using a Data Access Layer Component from ASP.NET • Add a ProductList.aspx • Add a GridView and ObjectDataSource to the page • Set up the ObjectDataSource to use the TableAdapter • Set up the GridView to use the ObjectDataSource • AutoFormat GridView and select Paging/Updating/Deleting etc.
DetailsView and FormView Controls • Used to display the "detail" of a record • Common Scenario: Master/Detail with GridView control as Master • DetailsView is lightweight, does not support templates, suitable for “no code” scenarios • FormView supports templates
DEMO: Using the DetailsView control • Add a Hyperlink column to the GridView, with a link to a ProductDetail.aspx?ProductId={0} • Create a ProductDetail.aspx page with a DetailsView control • Add an ObjectDataSource that uses the GetDataById method of our DAL component • accept input from QueryString ProductId • Autoformat and select Update/New/Delete options
Master Pages • In .NET 1.x, User controls were used for consistent look and feel across pages • Master Pages are similar, when a page is requested, it is merged with it's Master Page before being returned to the user
DEMO: Master Pages • Select Add New Item/Master Page • Add some header and footer info • Can optionally add default content • Add a new Webform and check the "Select Master Page" checkbox • open existing Webforms and add: • Page attribute MasterPageFile="~/MasterPage.master" • ASP Control<asp:Content runat="server" ContentPlaceHolderID=ContentPlaceHolder1> • Test the Webform
Themes • Maintain consistent appearance and layout across web app • Skins • collection of property values that determine the visual appearance of a specific type of control • Examples: background and foreground colors of a Button control or the font type and size used in a GridView control. • Themes • a named collection of skins, images, and CSS style sheets that can be applied to an entire Web application • Any controls contained in pages to which the theme applies will have the appropriate skins and styles applied to them before they are rendered
Demo: Themes • Create a new folder in the \Themes folder of your application. • The name of the folder you create is the name of the page theme. For example, if you create a folder \Themes\MyFirstTheme, the name of your page theme is MyFirstTheme. • Add a base style sheet to the theme: • In Solution Explorer, right-click the Themes folder, click Add New Item, click StyleSheet, and then click OK. • You can tailor the style sheet by using traditional CSS syntax. • Create a Skin • Create a new text file in your named theme folder with a .skin extension. • The typical convention is to create one .skin file per control, such as Button.skin or Calendar.skin. • In the .skin file, add a normal control definition (using declarative syntax), but include only the properties you want to set for the theme. • Use the Theme • Can be applied to individual pages using directive:<%@ Page theme="ThemeName" ... %> • Can be applied to entire site in web.config under <system.web> add <pages theme="ThemeName" />
Site Map Navigation • Used for defining layout of site, menus and navigation. • Includes controls for menu system and treeview • Also has “bread crumb” control (SiteMapPath)
Demo: Site Map Navigation • add a site Map file • default provider ("FileMapProvider") based on XML • define link site structure • now a SiteMap property will be exposed on each page. • SiteMap.CurrentNode.ParentNode • SiteMap.CurrentNode.Title • Add SitMapPath and Menu Control to Master Page • can use built-in navigation controls (Navigation section in toolbox) • Menu control with flyout • TreeView control • Databind to SiteMap provider • to add hierarchies, add a new SiteMapNode in XML hierarchy • to add "Bread Crumbs" use the SiteMapPath control
Much more in 2005! • Team System • WindowsForms Controls • Web Parts • Membership and Role Management • Website Admin Tool • ...
For Swag!!! • What new ASP.NET component allows data binding of a middle-tier Business Logic Class with UI controls?
For Swag!!! • What two new ASP.NET controls can be used to display the “Detail” of a record?
For Swag!!! • What is the new marketing name for Windows “Longhorn?”