ASP.NET
Mine is the pattern...
Software is broken, from the first version
Fowler has spoken, his gospel word.
Praise for the patterns, praise for MVP
Praise for our passive view of our world.
Hear there's a new thought, coming from Redmond
Wait it's an old thought we already had.
Praise for MVC, in its new format
Sprung in completeness where their feet pass.
Mine is a castle, and it's named Windsor
Born not from one light, silver or gray.
Praise it with caution, praise it with warning
MS' recreation of the new way.
(C) MVVMVPVC
The ASP.NET, Silverlight, PHP, Rails Experiment
I've been working with Microsoft technologies for over ten years, specifically Microsoft's web development technologies. During that time I have built a variety sites ranging in scope from e-commerce, educational, service provision, SaaS, to dashboards, portals, internal tools, and even SAP-migration. While I praise the technology stack for what it allows me to do, it also comes with a whole host of limitations that make it hard for me to deliver the experience my clients would like. Throughout this decade of web development I have heard a lot from those around me about alternative technology stacks that...
JavaScript Print Button
To implement a print button on a web page, you can use the window.print() javascript function. The following example shows an image that is displaying a printer icon and will print the current page when clicked.
Code:
<img border="0" onclick="window.print();" src="/images/PrintIcon.gif" style="cursor:hand;" />
(Replace the text /images/PrintIcon.gif with the location of an icon in your site.)
Example:
A better application of this idea is to first create a page that renders a print preview of the information you want to print. This print preview will look similar to the original page but will not contain navigation items, header images, or other page clutter. Furthermore, the data can be formatted...
VSLive! Day Two - Creating Custom Data Source Controls
Presenter: Rocky Lhotka
Code: http://www.lhotka.net
This discussion contains information about creating custom data source controls. Before diving into the concepts involved, lets first consider a justification for such development. This is provided in the form of an analysis of the two most commonly used controls that are available for that purpose:
SqlDataSource
The SqlDataSource object allows developers to retrieve data from a database directly and use data-binding to display and edit the data inside of web or windows forms. However, this is really only useful in 2-tier applications and leads to a poor architecture. I find the SqlDataSource control to be most useful in prototyping.
ObjectDataSource
The ObjectDataSource, while vastly...
VSLive! Day One - Architecting ASP.NET Applications Part 7 - State Management
Session Management
In much the same way as the configuration management class was written, a session management class can be written to encapsulate access to session variables. This allows for first-class properties to be used when writing to and reading from session. This provides for Intellisense when working with session variables as well as garnering the advantage of receiving compile-time errors when mistakes are made while architecting the session management class.
Page Request Life Cycle
The following diagram was shared by Paul because the workshop had ended a little early. It's a picture I've had in my mind ever since I started developing ASP.NET pages, but...
VSLive! Day One - Architecting ASP.NET Applications Part 6 - Skins and Themes
Skins & Themes
Styling complex controls such as Calendars and GridViews can be very difficult because of the way in which they render. To address this problem, Microsoft developed the concept of skins and themes. Skins and themes can be thought of as a server-side version of style sheets.
Skins
Skin files have a .skin file extension. They live in the "App_Themes" folder. There are two types of control skins: default skins and named skins. Default skins apply to all controls of the same type when a Theme is applied to a page. Default skins do not have a SkinID attribute. Named skins have a SkinID attribute set and...
VSLive! Day One - Architecting ASP.NET Applications Part 5 - CSS
Structure versus Design
The structure of a web page is the physical HTML elements (not the server controls) as opposed to the design which is the application of styles such as color, font size, or setting whether some text is bold. Cascading style sheets provide a mechanism for separating the structure of a page from its design. This is desirable because it removes duplication within the structure of a page. Fixing errors with styles that are declared inline with the structure of a page can be very time consuming: i.e. if a color=blue is declared on every td (table cell) within a page and...
VSLive! Day One - Architecting ASP.NET Applications Part 4 - Exception Handling
Exception Providers
Exception providers can be used to publish exception information to a variety of sources. This is useful because user's of an application often fail to capture exception information when they encounter a failure. To address this, an ExceptionManager class could be developed to publish exception information to a collection of subscribers. These subscribers might be common destinations such as the event log, a table in a database, a file on disk, or an email address. When an exception is caught, something along the lines of:
try {
... some code ...
}
catch (System.Exception ex) {
ExceptionManager.Publish(ex);
}
could be used to invoke the functionality of a ExceptionManager class. The purpose...
VSLive! Day One - Architecting ASP.NET Applications Part 3 - Example Providers
Encapsulating ADO.NET
A couple of real world examples of providers that are useful in almost every application are that of an encapsulated data access layer and a configuration management component. Data access layers use providers to perform dependency injection, allowing for multiple different implementations of a set of data access interfaces, with each implementation exposing functionality to communicate with different data sources. This is a fairly common form of encapsulation that many developers are already familiar with implementing, but there are still many areas in which the correct provider and package design can return many architectural, maintenance, and extensibility benefits. Providers should be completely...
VSLive! Day One - Architecting ASP.NET Applications Part 2 - Custom Providers
Custom Providers
The second part of the discussion is opening with a discussion of custom provider development. This is of great interest to me as my recent work with the Model View Presenter pattern has caused me to research and implement dependency injection for many of the layers of my application. The current product that I'm working on is implementing the MVP pattern and is using dependency injection to dynamically load a data layer at run time. There is a need within the product to use a different data access layer assembly for the administrative tools than for the public side of the application. The...
VSLive! Day One - Architecting ASP.NET Applications Part 1
Getting Situated
For the preconference, I decided to attend Paul Sherrif's talk on Architecting ASP.NET Applications. Fortunately, I was able to get to the room about an hour early and find one of the few seats situated close to a power outlet. I really didn't want to have to transfer my notes from paper to my laptop later; I'd rather just type them out directly!
N-Tier Development Benefits
The workshop has begun with a discussion of n-tier development; the benefits of logically separating services into different libraries and isolating functionality into discreet sections. The advantages of this approach are that the maintenance and extension of...
SqlDependency - Creating a Smarter Cache
I recently got the chance to learn about a technology that has interested me for quite some time: SQL dependencies. The premise of my encounter with SqlDependency was to create a smarter cache. The project I'm currently working on was employing a sliding expiration policy to invalidate the contents of a cache of database lookup values and I proposed some research be conducted into using SQL dependencies to automatically invalidate the cache items when the corresponding database contents were changed. I had experimented with the SQL dependency classes when .NET 2.0 was first released using a test SQL 2000 database. The example I was...
The ObjectDataSource Web Control
There exists a wide variety of ways in which data for a web page can be retrieved from a data store. One of the ways introduced in ASP.NET 2.0 involves using the ObjectDataSource control. This article discusses the ObjectDataSource control and how it fits into the ASP.NET 2.0 toolkit. A working example is provided demonstrating how the ObjectDataSource control can be used with a typed data set to provide search results to a GridView that are filtered based upon search parameters entered into other controls on the same page. The results can be paged and sorted within the grid, demonstrating...
CascadingDropDownList and Page Validation
While working with the AJAX Control Toolkit (http://ajax.asp.net), I came across something interesting with the CascadingDropDownList control and ASP.NET page validation.
What Does the CascadingDropDownList Do?
The control is used to create tiered drop-down lists that each depend upon parent values for their own data population. The canonical example given regards using three DropDownList controls to narrow a selection of a car. The first list displays a list of manufacturers, the second a list of models, and the final a list of common packages, with each successive list control populating only the relevant values based upon its parent. For example, selecting "Ford" from the manufacturer list would...