Google
 

Wednesday, June 3, 2009

Windows Presentation Foundation (WPF)

The Windows Presentation Foundation (WPF), as its name implies, is the new
Microsoft standard for creating user interfaces. WPF is a consolidation of
previously used presentation technologies including Windows Forms, GDI+, Windows
Media Player, and DirectX. WPF provides the following benefits:


  • A common platform and environment for developing cutting edge user
    interfaces that combines all previously used Microsoft presentation
    technologies.
    WPF is capable of interacting with all of the previous
    technologies to aid in progressive application upgrades. All Microsoft
    presentation development going forward should use WPF or the subset of WPF,
    Silverlight.
  • The ability for developers and designers to work together,
    simultaneously on projects
    - a result of the proper division of markup from
    code and the correct usage of tools.
  • A common and standardized technology that can be used for both Windows
    and Web applications.
    WPF offers the ability to create standalone WPF
    applications which are analogous to Windows Forms applications and to create
    XAML Browser Applications (XBAPs) - the same WPF applications hosted in a Web
    browser and subject to more stringent security settings.

The features included in the WPF standard are:


  • A complete application framework integrated into the .NET Framework 3.0
  • Layout control and user interface controls
  • Complete support for styles and templates
  • Advanced text formatting and display capabilities (through ClearType) that
    greatly improve text readability
  • Support for both fixed layout and flow layout documents and the introduction
    of a brand new fixed document format standard known as the XML Paper Specification (XPS) document standard
  • Easy display and integration of all image formats, video, audio, 2D
    graphics, 3D graphics as well as graphics transformations and effects and
    animations
  • Advanced data binding capabilities

What's New in the .NET Framework

The .NET Framework can also be fully extended by developers to create custom
classes and types. The functionality of the .NET Framework spans the server, the
workstation, and the Web. The four primary additions to the .NET Framework as of
version 3.0 are:


  1. Windows Presentation Foundation (WPF)
  2. Windows Communication Foundation (WCF)
  3. Windows Workflow Foundation (WF)
  4. CardSpace

Windows Presentation Foundation (WPF)


WPF is used to develop elaborate user interfaces like those that adorn
Windows Vista and managed advanced media streaming and integration. WPF is the a
complete revamp of Windows Forms so that user interface, graphic, and media
development is now designed around the .NET Framework.


Windows Communication Foundation (WCF)


WCF encompasses the ASP.NET Web Services and .NET remoting functionality that
was contained in the .NET Framework 2.0 as well as new communication
technologies.


Windows Workflow Foundation (WF)


WF is used to model complex workflow processes.


CardSpace


CardSpace is the embodiment of new security and user authorization
functionality.

What is Silverlight?

Silverlight is a new cross-browser, cross-platform
implementation of the .NET Framework for building and delivering the next
generation of media experiences and Rich Interactive Applications(RIA) for the
web. It runs in all popular browsers, including Microsoft Internet Explorer,
Mozilla Firefox, Apple Safari, Opera. The plugin required to run Silverlight is
very small in size hence gets installed very quickly.


It is combination of different technolgoies into a single
development platform that allows you to select tools and the programming
language you want to use. Silverlight integrates seamlessly with your existing
Javascript and ASP.NET AJAX code to complement functionality which you have
already created.


Silverlight aims to compete with Adobe Flash and the
presentation components of Ajax. It also competes with Sun Microsystems' JavaFX,
which was launched a few days after Silverlight.


Currently there are 2 major versions of Silverlight:


Silverlight 1.0 and Silverlight 2.0( previously referred to
as version 1.1).


Main features of Silverlight 2.0 :


  1. A built-in CLR engine that delivers a super high performance
    execution environment for the browser. Silverlight uses the same core CLR engine
    that we ship with the full .NET Framework.
  2. Silverlight includes a rich framework library of built-in
    classes that you can use to develop browser-based applications.
  3. Silverlight includes support for a WPF UI programming model.
    The Silverlight 1.1 Alpha enables you to program your UI with managed code/event
    handlers, and supports the ability to define and use encapsulated UI controls.
  4. Silverlight provides a managed HTML DOM API that enables you
    to program the HTML of a browser using any .NET language.
  5. Silverlight doesn't require ASP.NET to be used on the
    backend web-server (meaning you could use Silverlight with with PHP on Linux if
    you wanted to).
  6. Silverlight 2 includes Deep Zoom, a technology derived from
    Microsoft Live Labs Seadragon. It allows users to zoom into, or out of, an image
    (or a collage of images), with smooth transitions, using the mouse wheel. The
    images can scale from 2 or 3 megapixels in resolution into the gigapixel range,
    but the user need not wait for it to be downloaded entirely; rather, Silverlight
    downloads only the parts in view, optimized for the zoom level being viewed.
  7. Silverlight 2 also allows limited filesystem access to
    Silverlight applications. It can use the operating system's native file dialog
    box to browse to any file (to which the user has access).

Tuesday, February 19, 2008

Does SQL Server have anything like VB's On Error GoTo?

To those familiar with Visual Basic, VB provides the option to use the ON ERROR GOTO ... clause to catch practically any error and handle it in one's program.Does SQL Server 2000 have the analogous clause that will jump to a certain part of code in a stored procedure to handle errors?Solution: Errors must be checked after every SQL statement of interest.In short: No! SQL Server does not have anything like Visual Basic's "On Error GoTo" construct. It acts as if there was always an "On Error Resume Next" statement in effect.For effective error handling in a SQL Server stored procedure you must test the value of @@ERROR after EVERY SQL statement that might produce an error. Yes, that's a lot of testing. A well written stored procedure will often be 1/2 or more error handling code.There's another important consideration in designing error handling: @@ERROR is reset after each and every SQL statement, @@ROWCOUNT is also similarly reset. Therefore, you must capture both of these immediatly after each SQL statement that might produce an error. I start by declaring two variables to hold the values of @@ERROR and @@ROWCOUNT while the error handling code is working with them. They're declared at the top of every stored procedure and I've added them to my stored procedure template.
DECLARE @myERROR int -- Local @@ERROR , @myRowCount int -- Local @@ROWCOUNT
Next let's say that we had a simple INSERT statement
INSERT INTO Authors (au_id, au_fname, au_lname, contract) VALUES ('1234' , 'Arun, 'paramesh' , 1 )
Immediately after that statement, you should have the following statement:
SELECT @myERROR = @@ERROR , @myRowCOUNT = @@ROWCOUNT
These two assignements must be in the same statement. If you were to split them into two statements, for instance:
SET @myERROR = @@ERRORSET @myRowCOUNT = @@ROWCOUNTthen @myRowCOUNT
would always be zero. That's because it's reflecting the number of rows effected by the
SET @myERROR = @@ERROR statement that preceeds it.
Thanks,
Arun.

Thursday, January 24, 2008

ASP.NET Web Forms


The ASP.NET Web Forms page framework is a scalable common language runtime programming model that can be used on the server to dynamically generate Web pages.
Intended as a logical evolution of ASP (ASP.NET provides syntax compatibility with existing pages), the ASP.NET Web Forms framework has been specifically designed to address a number of key deficiencies in the previous model. In particular, it provides:


  • The ability to create and use reusable UI controls that can encapsulate common functionality and thus reduce the amount of code that a page developer has to write.

  • The ability for developers to cleanly structure their page logic in an orderly fashion (not "spaghetti code").

  • The ability for development tools to provide strong WYSIWYG design support for pages (existing ASP code is opaque to tools).


  • ASP.NET Web Forms pages are text files with an .aspx file name extension. They can be deployed throughout an IIS virtual root directory tree. When a browser client requests .aspx resources, the ASP.NET runtime parses and compiles the target file into a .NET Framework class. This class can then be used to dynamically process incoming requests. (Note that the .aspx file is compiled only the first time it is accessed; the compiled type instance is then reused across multiple requests).
    An ASP.NET page can be created simply by taking an existing HTML file and changing its file name extension to .aspx (no modification of code is required). For example, the following sample demonstrates a simple HTML page that collects a user's name and category preference and then performs a form postback to the originating page when a button is clicked:


    ASP.NET provides syntax compatibility with existing ASP pages. This includes support for <% %> code render blocks that can be intermixed with HTML content within an .aspx file. These code blocks execute in a top-down manner at page render time.

    ASP.NET page developers can utilize code blocks to dynamically modify HTML output much as they can today with ASP. For example, the following sample demonstrates how code blocks can be used to interpret results posted back from a client.

    While code blocks provide a powerful way to custom manipulate the text output returned from an ASP.NET page, they do not provide a clean HTML programming model. As the sample above illustrates, developers using only code blocks must custom manage page state between round trips and custom interpret posted values.

    Friday, November 2, 2007

    ASP.NET Configuration Files

    The Microsoft® ASP.NET configuration system features an extensible infrastructure that enables you to define configuration settings when your ASP.NET applications are first deployed so that you can add or revise configuration settings at any time with minimal impact on operational Web applications and servers.


    The ASP.NET configuration system provides the following benefits:

    Configuration information is stored in XML-based text files. You can use any standard text editor or XML parser to create and edit ASP.NET configuration files.

    ASP.NET allows configuration settings to be stored together with static content, dynamic pages, and business objects within a single application directory hierarchy. A user or administrator simply needs to copy a single directory tree to set up an ASP.NET Framework application on a machine

    Configuration data is stored in plain text files that are both human-readable and human-writable. Administrators and developers can use any standard text editor, XML parser, or scripting language to interpret and update configuration settings.

    Multiple configuration files, all named Web.config, can appear in multiple directories on an ASP.NET Application server. Each Web.config file applies configuration settings to its own directory and all child directories below it. Configuration files in child directories can supply configuration information in addition to that inherited from parent directories, and the child directory configuration settings can override or modify settings defined in parent directories. The root configuration file named systemroot\Microsoft.NET\Framework\versionNumber\CONFIG\Machine.config provides ASP.NET configuration settings for the entire Web server.

    At run time, ASP.NET uses the configuration information provided by the Web.config files in a hierarchical virtual directory structure to compute a collection of configuration settings for each unique URL resource. The resulting configuration settings are then cached for all subsequent requests to a resource. Note that inheritance is defined by the incoming request path (the URL), not the file system paths to the resources on disk (the physical paths).

    ASP.NET provides an extensible configuration infrastructure that enables third-party developers to store their own configuration settings, define the persistence format of their own configuration settings, intelligently participate in their processing, and control the resulting object model through which those settings are ultimately exposed.

    Changes to ASP.NET configuration files are automatically detected by the system and are applied without requiring any user intervention (in other words, an administrator does not need to restart the Web server or reboot the machine for them to take effect).

    The ASP.NET configuration system is extensible. You can define new configuration parameters and write configuration section handlers to process them.

    ASP.NET helps protect configuration files from outside access by configuring Internet Information Services (IIS) to help prevent direct browser access to configuration files. HTTP access error 403 (forbidden) is returned to any browser attempting to request a configuration file directly.

    ASP.NET Page Life Cycle

    A page in an ASP.NET application consists of several server controls. These are the fundamental building blocks of an ASP.NET application. The Life cycle of an ASP.NET page, depends on whether the page is requested for the first time or it is a postback. Postback is a process by which a page can request for itself.

    When the Page is requested for the first time


    The Life Cycle of a page when requested for the first time:

    Initializing: During this phase, the server creates an instance of the server control

    Loading: During this phase, the instance of the control is loaded onto the page object in which it is defined.

    PreRendering: During this phase, the control is updated with the changes made to it. This prepares the control for rendering.

    Saving: During this phase, the state information of the control is saved. For example, if a value is set for the control during the Load event, it is embedded in the HTML tag that will be returned to the browser.

    Rendering: During this phase, the server creates the corresponding HTML tag for the control.

    Disposing: During this phase, all cleanup tasks, such as closing files and database connections opened by the control are performed.

    Unloading: During this phase, all cleanup tasks, such as destroying the instances of server control are performed. This is the final event in the life cycle of a server control

    Life cycle when the page processed during a postback event
    The processing sequence in which a page is processed during a postback event is:

    Initializing: During this phase, the server creates an instance of the server control

    Loading view state: During this phase, the view state of the control posted by the client is reloaded into the new instance of the control.

    Loading: During this phase, the instance of the control is loaded onto the page object in which it is defined.

    Loading the postback data: During this phase, the server searches any data corresponding to the control that is loaded in the data posted by the client.

    PreRendering: During this phase, the control is updated with the changes made to it. This prepares the control for rendering.

    Saving state: During this phase, the change in the state of control between the current request and the previous request of the page is saved. For each change, the corresponding event is raised. For example, if the text of a textbox is changed, the new text is saved and a text_change event is raised.

    Rendering: During this phase, the server creates the corresponding HTML tag for the control.

    Disposing: During this phase, all cleanup tasks, such as closing files and database connections opened by the control are performed.

    Unloading: During this phase, all cleanup tasks, such as destroying the instances of server control are performed. This is the final event in the life cycle of a server control

    The events associated with the relevant page cycle phases are:

    Page Initialization: Page_Init

    View State Loading:LoadViewState

    Postback data processing: LoadPostData

    Page Loading: Page_Load

    PostBack Change Notification: RaisePostDataChangedEvent

    PostBack Event Handling: RaisePostBackEvent

    Page Pre Rendering Phase: Page_PreRender

    View State Saving: SaveViewState

    Page Rendering: Page_Render

    Page Unloading: Page_UnLoad

    The following figure illustrates how the server controls on an ASP.NET page is processed by the server: