Tuesday, April 22, 2008

ASP.NET Overview

ASP.NET Overview

ASP.NET is a unified Web development model that includes the services necessary for you to build enterprise-class Web applications with a minimum of coding. ASP.NET is part of the .NET Framework, and when coding ASP.NET applications you have access to classes in the .NET Framework. You can code your applications in any language compatible with the common language runtime (CLR), including Microsoft Visual Basic, C#, JScript .NET, and J#. These languages enable you to develop ASP.NET applications that benefit from the common language runtime, type safety, inheritance, and so on.
ASP.NET includes:

  • A page and controls framework
  • The ASP.NET compiler
  • Security infrastructure
  • State-management facilities
  • Application configuration
  • Health monitoring and performance features
  • Debugging support
  • An XML Web services framework
  • Extensible hosting environment and application life cycle management
  • An extensible designer environment

Page and Controls Framework
The ASP.NET page and controls framework is a programming framework that runs on a Web server to dynamically produce and render ASP.NET Web pages. ASP.NET Web pages can be requested from any browser or client device, and ASP.NET renders markup (such as HTML) to the requesting browser. As a rule, you can use the same page for multiple browsers, because ASP.NET renders the appropriate markup for the browser making the request. However, you can design your ASP.NET Web page to target a specific browser, such as Microsoft Internet Explorer 6, and take advantage of the features of that browser. ASP.NET supports mobile controls for Web-enabled devices such as cellular phones, handheld computers, and personal digital assistants (PDAs).
ASP.NET Web pages are completely object-oriented. Within ASP.NET Web pages you can work with HTML elements using properties, methods, and events. The ASP.NET page framework removes the implementation details of the separation of client and server inherent in Web-based applications by presenting a unified model for responding to client events in code that runs at the server. The framework also automatically maintains the state of a page and the controls on that page during the page processing life cycle. For more information see ASP.NET Web Pages Overview.
The ASP.NET page and controls framework also enables you to encapsulate common UI functionality in easy-to-use, reusable controls. Controls are written once, can be used in many pages, and are integrated into the ASP.NET Web page that they are placed in during rendering.
The ASP.NET page and controls framework also provides features to control the overall look and feel of your Web site via themes and skins. You can define themes and skins and then apply them at a page level or at a control level. For more information, see ASP.NET Themes and Skins Overview.
In addition to themes, you can define master pages that you use to create a consistent layout for the pages in your application. A single master page defines the layout and standard behavior that you want for all the pages (or a group of pages) in your application. You can then create individual content pages that contain the page-specific content you want to display. When users request the content pages, they merge with the master page to produce output that combines the layout of the master page with the content from the content page. For more information see ASP.NET Master Pages Overview.

ASP.NET Compiler
All ASP.NET code is compiled, which enables strong typing, performance optimizations, and early binding, among other benefits. Once the code has been compiled, the common language runtime further compiles ASP.NET code to native code, providing improved performance.
ASP.NET includes a compiler that will compile all your application components including pages and controls into an assembly that the ASP.NET hosting environment can then use to service user requests. For more information, see ASP.NET Compilation Overview.


Security Infrastructure
In addition to the security features of .NET, ASP.NET provides an advanced security infrastructure for authenticating and authorizing user access as well as performing other security-related tasks. You can authenticate users using Windows authentication supplied by IIS, or you can manage authentication using your own user database using ASP.NET forms authentication and ASP.NET membership. Additionally, you can manage the authorization to the capabilities and information of your Web application using Windows groups or your own custom role database using ASP.NET roles. You can easily remove, add to, or replace these schemes depending upon the needs of your application. For more information see the following topics:
Securing ASP.NET Web Sites
Managing Users by Using Membership
Managing Authorization Using Roles
Forms Authentication Provider
ASP.NET always runs with a particular Windows identity so you can secure your application using Windows capabilities such as NTFS Access Control Lists (ACLs), database permissions, and so on. For more information on the identity of ASP.NET, see Configuring ASP.NET Process Identity and ASP.NET Impersonation.


State-Management Facilities
ASP.NET provides intrinsic state management functionality that enables you to store information between page requests, such as customer information or the contents of a shopping cart. You can save and manage application-specific, session-specific, page-specific, user-specific, and developer-defined information. This information can be independent of any controls on the page.
ASP.NET offers distributed state facilities, which enable you to manage state information across multiple instances of the same application on one computer or on several computers. For more information see ASP.NET State Management Overview.

ASP.NET Configuration
ASP.NET applications use a configuration system that enables you to define configuration settings for your Web server, for a Web site, or for individual applications. You can make configuration settings at the time your ASP.NET applications are deployed and can add or revise configuration settings at any time with minimal impact on operational Web applications and servers. ASP.NET configuration settings are stored in XML-based files. Because these XML files are ASCII text files, it is simple to make configuration changes to your Web applications. You can extend the configuration scheme to suit your requirements. For more information see ASP.NET Configuration Overview.

Health Monitoring and Performance Features
ASP.NET includes features that enable you to monitor health and performance of your ASP.NET application. ASP.NET health monitoring enables reporting of key events that provide information about the health of an application and about error conditions. These events show a combination of diagnostics and monitoring characteristics and offer a high degree of flexibility in terms of what is logged and how it is logged. For more information see ASP.NET Health Monitoring Overview.
ASP.NET supports two groups of performance counters accessible to your applications:
The ASP.NET system performance counter group
The ASP.NET application performance counter group
For more information, see Monitoring ASP.NET Application Performance.


Debugging Support
ASP.NET takes advantage of the run-time debugging infrastructure to provide cross-language and cross-computer debugging support. You can debug both managed and unmanaged objects, as well as all languages supported by the common language runtime and script languages. For details, see ASP.NET Debugging.
In addition, the ASP.NET page framework provides a trace mode that enables you to insert instrumentation messages into your ASP.NET Web pages. For more information see What's New in ASP.NET Tracing.

XML Web Services Framework
ASP.NET supports XML Web services. An XML Web service is a component containing business functionality that enables applications to exchange information across firewalls using standards like HTTP and XML messaging. XML Web services are not tied to a particular component technology or object-calling convention. As a result, programs written in any language, using any component model, and running on any operating system can access XML Web services. For more information, see XML Web Services Using ASP.NET.


Extensible Hosting Environment and Application Life-Cycle Management
ASP.NET includes an extensible hosting environment that controls the life cycle of an application from when a user first accesses a resource (such as a page) in the application to the point at which the application is shut down. While ASP.NET relies on a Web server (IIS) as an application host, ASP.NET provides much of the hosting functionality itself. The architecture of ASP.NET enables you to respond to application events and create custom HTTP handlers and HTTP modules. For more information see ASP.NET Application Life Cycle Overview for IIS 5.0 and 6.0.


Extensible Designer Environment
ASP.NET includes enhanced support for creating designers for Web server controls for use with a visual design tool such as Visual Studio. Designers enable you to build a design-time user interface for a control, so that developers can configure your control's properties and content in the visual design tool. For more information see ASP.NET Control Designers Overview.
See Also

Concepts
ASP.NET Application Life Cycle Overview for IIS 5.0 and 6.0
ASP.NET Web Pages Overview

Visual Studio 2005 - IDE Enhancements

IDE Enhancements
IDE Enhancements
IDE Simplification
Class Designer
Exporting/Importing Options Settings
Smart Tags for Controls
Snaplines
Data Tips
Edit and Continue
Exception Assistant
Code Editing
Line Revision Marks
IntelliSense Improvements
IntelliSense Code Snippets
Source Browsing
Windows Forms
Windows Forms Overview
Video Overview
UI Development
ToolStrips, LayoutPanels, SplitContainer, Menus, StatusStrips
WebBrowser
XP Theme Support
Data Centric Applications
Configure Data Source Wizard and Data Sources Window
Data-Controls
BindingSource
BindingNavigator
DataGridView
MaskedTextBox
Attaching a Database with Your Application Displaying Data from a Web Service -->
Displaying Data from a Business Object
Connect the Dots
Performing Tasks Asynchronously
Deployment
ClickOnce
VSTO
VSTO Overview
Video Overview
Building UI
Smart Docs
Actions Pane
Smart Tags
Data-Centric Applications
XML Support, Separation of view from Data, Data Binding, Data Caching
Displaying Data from a Web Service
Displaying Data from a Database
Displaying Data from XML Source
Enhanced Data Binding
.NET CF
Overview
Video Overview
.NET Framework Enhancements
Authentication
Web Services
Multi-Threading Capability
COM Interop
Support for IPv6
Security
Building UI
DocumentList and ComboBox
MonthCalendar, DateTimePicker, PictureBox, ProgressBar
Help Interaction with Notifications
HardwareButton and ScreenOrientation
Data Binding
Data-Centric Applications
IDE Integration
Web Service Support
SQL 2005 Mobile Edition
Synchronization and Replication
Web Services
Testing
Deployment
Smart Client
Smart Client Overview
Rich User Experience
Web Services Offline & Online Support
Easy Deployment and Change Management
Device Adaptability
Responsiveness
Local Resource Utilization
Building Applications
Building and Debugging
New Build System
Large Builds
Multi-Processor Builds
Home Professional Set default to show samples in VB C# C++ J#

Windows Forms - XP Theme Support
Visual Studio 2005 improves support for Windows XP Themes in Windows Forms 2.0. Windows XP Theme support allows your Windows Form applications to have a completely modern and up-to-date look and feel. In the past, many of you had difficulty implementing the Windows XP look and feel for you client applications. It was particularly confusing when dealing with EnableVisualStyles() and trying to figure out why certain controls still wouldn't render properly. Moreover, you had to set each control's FlatStyle property to System.

All of these issues have been fixed in Windows Forms 2.0. Applications created with Visual Studio 2005 call EnableVisualStyles() by default. Additionally, the controls render properly without your having explicitly to set the FlatStyle property.
This walkthrough demonstrates Windows Forms 2.0's improved support for visual styles by building a simple application with controls for switching between four different visual styles.
See the Visual Studio 2005 Client Development Guided Tour Walkthrough Requirements page for a list of the requirements needed to run this walkthrough. NOTE: In addition to these requirements, this walkthrough requires the Windows XP operating system, configured to use the Windows XP style in the Display control panel Appearance tab.

1Open Visual Studio 2005 and create a new Windows Application project named "XP Themes". Using the Solution Explorer, open the Program.cs file. Note that visual styles have been enabled by default.
(NOTE: In Visual Basic you will need to click the Show All Files button in the Solution Explorer window before opening the designer partial file and then expand My Project Application.myapp and then open Application.Designer.vb. In J#, the designer-generated code is within a named region Windows Form Designer generated code in the Form1.jsl source code file.)
VB C# J#










2Switch over to the Form1 design view. Drag the following controls from the Toolbox onto Form1:
Button
CheckBox
ComboBox
TabControl
3Note that the controls appear with XP styling by default.
VB C# J#
VB C# J#













The new Application object property, VisualStyleState, can be used to enable visual styles selectively on client areas, non-client areas, or across the entire control. (The client area is the area inside the form, exclusive of the title bar and scroll bars.) By default, an application's VisualStyleState is ClientAndNonClientAreasEnabled. This means that the entire form, in terms of title bars and the client area, will be set to use XP Themes.
4Drag four RadioButton controls from the Toolbox onto Form1. Accept the default names. Resize the form to fit. In the Properties window, set each control's Text property to the following values, respectively:

radioButton1: ClientAndNonClientAreasEnabled
radioButton2: ClientAreaEnabled
radioButton3: NonClientAreaEnabled
radioButton4: NoneEnabled
VB C# J#
VB C# J#
VB C# J#


















Each of the RadioButton controls has a corresponding VisualStyleState enumeration value. Clicking one of the four RadioButton controls will assign the Application.VisualStyleState property to the corresponding value and refresh the Form. This demonstrates how to selectively enable visual styles.

5In the Properties window for radioButton1, click on the lightning bolt icon switch to the event. In the Click event, type radioButton_Click and press Enter. In the resulting handler add the following:
VB C# J#
If RadioButton1.Checked Then Application.VisualStyleState = _ VisualStyleState.ClientAndNonClientAreasEnabledElseIf RadioButton2.Checked Then Application.VisualStyleState = _ VisualStyleState.ClientAreaEnabledElseIf RadioButton3.Checked Then Application.VisualStyleState = _ VisualStyleState.NonClientAreaEnabledElseIf RadioButton4.Checked Then Application.VisualStyleState = _ VisualStyleState.NoneEnabledEnd If
' Repaint the form and all child controls.Me.Invalidate(True)
6To the top of Form1 add a reference to System.Windows.Forms.VisualStyles:
imports System.Windows.Forms.VisualStyles
VB
C#
J#
using System.Windows.Forms.VisualStyles;
VB
C#
J#
import System.Windows.Forms.VisualStyles.*;
7Right-click Form1 and select View Designer. In the Properties window for each of the three remaining RadioButton controls, set the Click event to radioButton_Click.
8Select the Debug Start Debugging menu command (F5) to run the application.
9In the running application, click each of the four RadioButton controls to see the effect of selectively enabling visual styles.












VB C# J#
if (radioButton1.Checked) { Application.VisualStyleState = VisualStyleState.ClientAndNonClientAreasEnabled; }else if (radioButton2.Checked) { Application.VisualStyleState = VisualStyleState.ClientAreaEnabled; }else if (radioButton3.Checked) { Application.VisualStyleState = VisualStyleState.NonClientAreaEnabled; }else if (radioButton4.Checked) { Application.VisualStyleState = VisualStyleState.NoneEnabled; }// Repaint the form and all child controls.this.Invalidate(true);
VB C# J#
if (radioButton1.get_Checked()){ Application.set_VisualStyleState( VisualStyleState.ClientAndNonClientAreasEnabled);}else if (radioButton2.get_Checked()){ Application.set_VisualStyleState( VisualStyleState.ClientAreaEnabled);}else if (radioButton3.get_Checked()){ Application.set_VisualStyleState( VisualStyleState.NonClientAreaEnabled);}else if (radioButton4.get_Checked()){ Application.set_VisualStyleState( VisualStyleState.NoneEnabled);}// Repaint the form and all child controls.this.Invalidate(true);
6To the top of Form1 add a reference to System.Windows.Forms.VisualStyles:
VB C# J#
imports System.Windows.Forms.VisualStyles
VB C# J#
using System.Windows.Forms.VisualStyles;
VB C# J#
import System.Windows.Forms.VisualStyles.*;
7Right-click Form1 and select View Designer. In the Properties window for each of the three remaining RadioButton controls, set the Click event to radioButton_Click.
8Select the Debug Start Debugging menu command (F5) to run the application.
9In the running application, click each of the four RadioButton controls to see the effect of selectively enabling visual styles.







































The first screenshot shows how the application looks when ClientAndNonClientAreasEnabled is selected. The entire application renders in the XP style. When only the client area is enabled all the controls on the Form reflect the XP style. The non-client areas, however, such as the Form border and its controls, do not. The remaining two options are reflected in the other screenshots.
In closing its worth pointing out that Visual Studio 2005 extends support for visual styles into owner-drawn controls as well. To draw your own control you can subclass the VisualStyleRenderer class, which includes methods for drawing different parts of the current theme. Use VisualStyleInformation class to determine details about the current style. You can use derived renderers, such as ButtonRenderer, to draw pieces of these controls in your own control, allowing you to leverage the rendering capabilities of existing controls. This allows you to draw your control through visual styles-aware parts of common controls, reducing the amount of custom rendering code required. You can tell what element parts are predefined by using VisualStyleRenderer.IsElementDefined method call. By using suitable renderers when available, and calling out to custom rendering code otherwise, you can future-proof your code, as future version of Windows Forms may add more elements and parts.
© 2006 Microsoft Corporation. All rights reserved. Terms of Use.
SetTabs();
FindHtmLinkNode();