Professional Documents
Culture Documents
.2.0 Beta2 Overview
.2.0 Beta2 Overview
0 and Visual
Studio 2005 Overview
Paul Litwin
Collaborative Data Services,
Public Health Sciences,
Fred Hutchinson Cancer Research Center
cds.fhcrc.org
plitwin@fhcrc.org
Role
Membership Profiles Configuration
and APIs
Services
Management
IDE Changes
2002-2005 Deep Training/Litwin Consulting, Inc. All Rights Reserved Worldwide. Unauthorized duplication is strictly prohibited.
Page 1
Getting Started with VS 2005
u No need to create a project
u Instead create a new Web Site
VS 2005 Highlights (1 of 6)
u Editor doesn’
doesn’t reformat HTML unless you
ask it to!
u Selection preserved when switching
between Design and Source (HTML)
views
u Can now validate HTML against
additional browsers and XHTML
u Edit and Continue is reborn!
VS 2005 Highlights (2 of 6)
u Code-behind and inline code are equal
Code-
citizens
l Full support for IntelliSense for both styles
l Choose your style in Add New Item dialog
u Source changes tracked in margin
l Unsaved changes in yellow
l Recently saved changes in green
2002-2005 Deep Training/Litwin Consulting, Inc. All Rights Reserved Worldwide. Unauthorized duplication is strictly prohibited.
Page 2
VS 2005 Highlights (3 of 6)
u IntelliSense works everywhere
l HTML
l Code
l Page directives
l Web.config
l Design view
n Technically these are smart tags
VS 2005 Highlights (4 of 6)
u Speaking of Config Files
l Three ways to edit settings
1. Use IntelliSense within web.config file
2. Select ASP.NET tab inside of IIS Admin
application, click Edit Configuration btn
n Extensive control of web.config settings
3. Select Website | ASP.NET Configuration
n Not as complete as IIS Admin tool
n Includes Security Setup wizard
n Works with non-
non-IIS sites
VS 2005 Highlights (5 of 6)
u Creating event handlers now consistent
across languages (VB or C#)
l Can do it from property sheet
for both languages
u Moving windows easier
l Thanks to window guides
u Toolbox categorizes controls
2002-2005 Deep Training/Litwin Consulting, Inc. All Rights Reserved Worldwide. Unauthorized duplication is strictly prohibited.
Page 3
VS 2005 Highlights (6 of 6)
u VS ships with personal Web server
l No need to create a virtual root
l Next version of Cassini Web server
u Lots of ways to connect to a site
n code analysis
n project portal
n lots more …
Hobbyists
Enthusiasts
2002-2005 Deep Training/Litwin Consulting, Inc. All Rights Reserved Worldwide. Unauthorized duplication is strictly prohibited.
Page 4
Expanding Visual Studio
Developer Tester
Project
VSTE/SD VSTE/ST Manager
Application
Team Explorer
Architect
Infrastructure VSTE/SA
Architect
Source Build
Control Server
Users & Web Browser
Management Project Work
Portal Items
Reporting
© 2002-2005 Deep Training/Litwin & AnalyticsInc.
Consulting, 13
Testers
Architects
Enterprise Devs
Consultants
Professionals
VB6 Devs
Part-Timers
Hobbyists
Students
Enthusiasts
© 2002-2005 Deep Training/Litwin Consulting, Inc. 14
Data Controls
2002-2005 Deep Training/Litwin Consulting, Inc. All Rights Reserved Worldwide. Unauthorized duplication is strictly prohibited.
Page 5
Binding Data to Controls
u ASP.NET 1.x supported rich 1- 1-way
binding syntax but you still had to write
quite a bit of code to get data in and out
of controls
u ASP.NET 2.0 supports two-
two-way
(read/write) binding with no code in
many situations
n AccessDataSource n SiteMapDataSource
n ObjectDataSource
2002-2005 Deep Training/Litwin Consulting, Inc. All Rights Reserved Worldwide. Unauthorized duplication is strictly prohibited.
Page 6
GridView Control
Example: GridView.aspx
u A “code
code--less
less”” DataGrid
u Walk
Walk--through of grid with automatic
sorting (ascending & descending),
pagination
1. Add GridView to page
2. Using GridView Tasks pane, choose
DataSource
3. Check EnablePaging & EnableSorting
The Single-
Single-Record Form Problem
u ASP.NET 1.x provided no help to the
developer having to create a single-
single -record
“form
form”” view of data
u ASP.NET 2.0 gives us two solutions
l DetailsView – fixed look (supports styles but no
field templates); can't get at individual fields
l FormView – fully templated (VS will generate basic
template for you); will work with validation controls
u Both support editing, pagination
2002-2005 Deep Training/Litwin Consulting, Inc. All Rights Reserved Worldwide. Unauthorized duplication is strictly prohibited.
Page 7
FormView vs. DetailsView
Controls
Navigation
u Three Pieces
1. Navigation SiteMap
n Web.sitemap XML file
n Allows you to create a sitemap for navigation
purposes
2. SiteMapDataSource
n Reads Web.sitemap file and makes available
to TreeView control
3. Controls
n TreeView – displays navigation tree
n Menu – displays flyout menus
n SiteMapPath – "breadcrumb" path
© 2002-2005 Deep Training/Litwin Consulting, Inc. 24
2002-2005 Deep Training/Litwin Consulting, Inc. All Rights Reserved Worldwide. Unauthorized duplication is strictly prohibited.
Page 8
Master Pages
u Major shortcoming of ASP.NET 1.x: lack
of any easy way to create page
templates that other pages can inherit
u Enter ASP.NET 2.0 Master Pages
l Easy and powerful way to create a common
layout for all (or a subset of) pages in site
l Support for multiple levels of master pages
l WYSIWYG support for master pages in
Visual Studio
2002-2005 Deep Training/Litwin Consulting, Inc. All Rights Reserved Worldwide. Unauthorized duplication is strictly prohibited.
Page 9
Login Controls and Security
2002-2005 Deep Training/Litwin Consulting, Inc. All Rights Reserved Worldwide. Unauthorized duplication is strictly prohibited.
Page 10
New Features at a Glance
Framework Controls
Role
Membership Profiles Configuration
and APIs
Services
Management
Forms Authentication
<authentication mode="Forms">
<forms name="name"
cookieless=UseCookie|UseUri|AutoDetect|
UseDeviceProfile
defaultUrl=[URL]
domain=domain name
loginUrl="url"
protection=" All |None|Encryption|Validation"
timeout="30"
path="/"
requireSSL="true| false "
slidingExpiration="true|false ">
</forms>
</authentication>
2002-2005 Deep Training/Litwin Consulting, Inc. All Rights Reserved Worldwide. Unauthorized duplication is strictly prohibited.
Page 11
Login Controls
u Login – log in users (goes on login page)
u LoginView – displays different views
based on whether user is authenticated
u PasswordRecovery – recover or reset
lost password
u LoginStatus – displays login or logout
link
u LoginName – displays login name for
authenticated users
u CreateUserWizard – steps user through
wizard to create new account
u ChangePassword – changes password
for user
Membership Service
u Saves you from having to manage users and
passwords
u Login controls may obviate need to directly work with
the classes in many cases
u Choice of providers (SQL Server, Access, etc.)
u Example Uses
l Authenticate User
n Membership.ValidateUser()
2002-2005 Deep Training/Litwin Consulting, Inc. All Rights Reserved Worldwide. Unauthorized duplication is strictly prohibited.
Page 12
Role Service
u Simplifies authorization using roles
u Manage roles at design time using ASP.NET
Web Admin tool
l Or use Roles and RoleProvider classes at runtime
u Use LoginView control to display custom
content per role
l Order RoleGroup elements from highest to lowest
precedence (e.g., Admin first, etc.)
u Or use User.IsInRole() method from code
Role Service
u Role data carried between pages by ASP.NET
using encrypted cookies
u Reduces round-
round-trips to database for role
information
2002-2005 Deep Training/Litwin Consulting, Inc. All Rights Reserved Worldwide. Unauthorized duplication is strictly prohibited.
Page 13
IsInRole Roles Example
Roles.aspx.cs
protected void Page_Load (…)
{
// Order by highest to lowest
if (User.IsInRole("Developers "))
lblRole.Text = "Developer. You rule!";
else if (User.IsInRole("Managers "))
lblRole.Text = "Manager. So?";
else if (User.IsInRole("Users "))
lblRole.Text = "Lowly user";
else
lblRole.Text = "Not logged in.";
}
Personalization Service
u No need to create fields in a database to
keep track of personalization data
u Allows you to strongly type your
personalization data
u You maintain personalization data in
user profiles
Creating a Profile
<profile
defaultProvider="AspNetSqlProvider">
<properties>
<add name="sex" type="System.String"/>
<add name="age" type="System.Int32" />
<add name="color"
type="System.String"/>
<add name="birthdate"
type="System.DateTime" />
</properties>
</profile>
2002-2005 Deep Training/Litwin Consulting, Inc. All Rights Reserved Worldwide. Unauthorized duplication is strictly prohibited.
Page 14
Reading/Writing Profile Data
Profiles.aspx
Personalization Profiles
u Especially useful for customizing…
customizing…
l Themes
l Web Parts
2002-2005 Deep Training/Litwin Consulting, Inc. All Rights Reserved Worldwide. Unauthorized duplication is strictly prohibited.
Page 15
Themes & Skins
u Theme
l Collection of property settings (skins) that
allow you to define a standard look of
pages and controls
u Skin
l Set of visual attributes applied to a control
What's Themable?
u Properties that control appearance
u Does not include content or behavior
attributes such as AllowPaging,
AutoPostback
2002-2005 Deep Training/Litwin Consulting, Inc. All Rights Reserved Worldwide. Unauthorized duplication is strictly prohibited.
Page 16
Creating a Theme – Steps
1. Add theme folder to app using Add Folder|Theme
folder
2. Add .aspx
. aspx page to theme folder.
3. Add controls to page
4. Customize the look of the controls
5. Remove ID attribute and any attributes that you do
not want to be part of theme (e.g., Text)
6. Add SkinID attribute to any control to create alternate
skins
7. Remove all non-
non-control content from file
8. Rename file to .skin extension
Applying Themes
u Add attribute to Page directive of page
l Theme attribute
n Theme settings override any local settings
l StyleSheetTheme attribute
n Local settings override theme settings
2002-2005 Deep Training/Litwin Consulting, Inc. All Rights Reserved Worldwide. Unauthorized duplication is strictly prohibited.
Page 17
Theme & Skin Example
Pumpkin\
Pumpkin \Orange.skin
Themes
u Can also be set dynamically from code
u Need to set theme in Page_PreInit event
2002-2005 Deep Training/Litwin Consulting, Inc. All Rights Reserved Worldwide. Unauthorized duplication is strictly prohibited.
Page 18
Other Topics
u Caching Enhancements
u Cross--Page Posting
Cross
u Compilation Improvements
u Validation Groups
Caching Dependencies
u Work with SQL Server 7/2000
l Works by ASP.NET polling database
u Work even better with SQL Server 2005
l No polling necessary
u Set a few
properties in
property sheet
2002-2005 Deep Training/Litwin Consulting, Inc. All Rights Reserved Worldwide. Unauthorized duplication is strictly prohibited.
Page 19
Creating SQL Cache Dependency
from Code
Cache.Insert("dsTitles",
dsCache, new
SqlCacheDependency("pubs",
"titles")
Cross--Page Posting
Cross
2002-2005 Deep Training/Litwin Consulting, Inc. All Rights Reserved Worldwide. Unauthorized duplication is strictly prohibited.
Page 20
Precompilation
u Precompile.axd precompiles sites in
place to avoid first-
first-access delays
Validation Groups
ValidGroups.aspx
<asp:RequiredFieldValidator ID="rfvSearchName"
Runat="server" ErrorMessage="Enter name."
ControlToValidate="txtSearchName"
ValidationGroup="NameSearch">
</asp:RequiredFieldValidator>
2002-2005 Deep Training/Litwin Consulting, Inc. All Rights Reserved Worldwide. Unauthorized duplication is strictly prohibited.
Page 21
Conclusion
u ASP.NET 2.0 is an exciting new update
u Visual Studio 2005 gets much better
u Data controls make two-
two-way data binding easy and
reduce code significantly
u Master pages make visual inheritance of a page template
a snap
u Numerous security enhancements make the management
of users, roles, profiles so much easier
u Themes allow you to provide a consistent & configurable
look to pages
u Other cools features include cache dependencies,
validation groups, x-
x-page posting, precompilation
precompilation,, etc.
u The above features and more make ASP.NET 2.0 / VS
2005 a must-
must-have upgrade
© 2002-2005 Deep Training/Litwin Consulting, Inc. 64
Thank You
u Download materials (slides/samples)
l cds.fhcrc.org
2002-2005 Deep Training/Litwin Consulting, Inc. All Rights Reserved Worldwide. Unauthorized duplication is strictly prohibited.
Page 22