Explore the Premium Content

Creating a Data Tier in ASP.NET

Every application starts with an idea, a thought or a need of some kind and the software of course becomes the solution. Once requirements have been gathered and the project vision is established the architects usually begin designing a logical framework for the application based on several factors.

It’s usually recommended no matter what the size or projected complexity of the application that there is some form of separation between interface logic, business rules and database logic. Creating this separation not only maintains a clean easier to read application but it also creates physically separate components which can then be reused in other areas or even deployed separately on other dedicated servers and invoked remotely.

A middle of the road approach is what most mid-sized applications will implement. Where most of the business logic will remain tied into the front end code and the database logic separated into another component and invoked as needed from the front end. This is still a 2-tier approach but it is definitely more favourable than having the database logic and SQL code embedded into the front end.

In this tutorial will we look at a fairly basic example of how to implement a database connection layer into an ASP.NET project which can then be invoked from your aspx pages in the code-behind. This style of approach bypasses all GUI wizards and connection/adapter controls which would normally be configured on the code-behind file. Instead we will push this logic into a separate component.

Note: Part 1 requires Visual Studio .NET running ASP.NET ver 1.1 and access to any version of SQL server. Both VB.NET and C# code samples will be provided

Important Note! This tutorial will ‘not’ demonstrate how to actually execute the database requests or link to a sample database. This tutorial provides the class required to create a proper database layer which you can then implement into your own applications on any SQL database of your choice. Reading samples tables or executing stored procedures for example are not demonstrated in this tutorial.

Read More

Display SubTotals in ASP.NET DataGrid

The DataGrid is of course a natural fit for display tabular sets of data in a web application and it does its job quite nicely with support for paging, sorting and even editing in place. As you develop your applications however you will inevitably come across a requirement which is not covered by the built in functionality.

For the sake of having a set of data to work with we’ll connect to the sample Northwind database provided with all installations of SQL server, and the sample application will be built using ASP.NET version 1.1

Note: A version of SQL server with the sample Northwind database is required for this tutorial. Both VB.NET and C# code samples will be provided.

Read More

Using Stored Procedures in ASP.NET

The architecture and implementation of an application’s data tier is always a strong primary focus for any developer. Without a data tier and connection to a backend your application would of course do nothing and all functionality in your application of course has to flow through the backend data store. Whether it be pulling data out or pushing it in the design of the data tier can make or break a good user experience from the front end.

While this principle is all well and good there are of course many developers who are not database designers or data tier architects and don’t have the expertise or skills to design proper n-tier componentized objects to support their data store.

Fortunately for these developers working on smaller scale applications there is a solution provided in Visual Studio .NET to allow more of a WYSIWYG database design interface that still allows you to leverage some of the more powerful aspects of database interaction without having to write code for it.

One of these more powerful database features is stored procedures. Stored procedures are normally supported by any large scale database server and provide a number of performance and design benefits. The #1 benefit is that your SQL code is encapsulated outside of your application. Meaning you can manage database changes and fixes without having to recompile and redeploy your application which is a great advantage.

While smaller scale database applications such as Microsoft Access support queries which are similar in principle to stored procedures, they usually require a separate data tier component and will not be covered in this tutorial.

This tutorial will focus on implementing stored procedures within SQL Server. Trial versions of SQL server can be freely downloaded and Visual Studio .NET also comes with a smaller scale MSDE for localized database installation and development testing on your local PC.

We’ll create a sample ASP.NET application which uses stored procedures to pull data out of the sample Northwind database that comes with SQL server, and we’ll also implement an update stored procedure and use parameters to push data back into the database, all of which is accomplished through a minimal amount of code and minimal database programming knowledge.

Note: This tutorial requires Visual Studio .NET running ASP.NET 1.1 as well as a version of SQL server or access to an SQL server on your network which contains the Northwind sample database. You may also link to another SQL sample database of your choice but you will need to modify the code and SQL syntax where applicable to suit your alternative database. Both VB.NET and C# code samples are provided

Read More

ASP.NET “Mini” Master/Detail Pattern

ASP.NET “Mini” Master/Detail Pattern

In ASP.NET 2.0 the master/detail pattern has undergone massive improvements, however when working with ASP.NET 1.1 and Visual Studio .NET 2003/2002 it is a much more manual process. There are hundreds of articles regarding this subject however the most common usage is with large amounts of data; meaning long lists, with subsets of data that can fill large forms.

Sometimes the amount of data is smaller and you need to develop a much more compact version of this pattern, providing your users with a quick and easy lookup for extra information regarding your entity, whatever it may be.

In this tutorial we’ll look at a compact or “mini” version of the master/detail pattern which uses a very small list of data presented in a DataGrid component, and selecting a row in the DataGrid will display a minimal amount of extra information on another details form contained in the same page.

In addition to the master/detail pattern we’ll also implement a few tips & tricks with the DataGrid component to give us a more usable control. Below is a list of other aspects covered in this tutorial:

  • Bound column concatenation: Binding more than one column in the data source to a
    single column on the DataGrid component without using code-behind
  • Primary Key lookup: Binding the primary key to a hidden field on the DataGrid for easy seeking of rows on selection
  • Select anywhere feature: Allowing the user to click on any cell on the DataGrid to invoke the SelectedIndexChanged event
  • Manual DataSet object construction: How to create a DataSet through code including a primary key column
  • Enable smart navigation to minimize page refresh visually

Although this tutorial is designed to be used in a more compact fashion the pattern itself can easily be migrated to larger implementations with larger volumes of data. This tutorial is not based on the new ASP.NET 2.0 implementation wizards for building master/detail pages; it is designed for ASP.NET 1.1.

Note: Visual Studio .NET running ASP.NET 1.1 is required for this tutorial. Both VB.NET and C# code samples will be provided

Read More
FREE

Free, Pure ASP Upload 3 - Upload Multiple Files at Once

Today we'll show you how to you can enable your users to upload multiple files at once with Pure ASP Upload and the Flash Based Upload Control. [view]

Get Pure Upload 3 read more

 

Read More

Export Calendar Items to Outlook 2K3

Export Calendar Items to Outlook 2K3

One of the advantages to working with Microsoft development platforms is that there are often convenient integration tools available to leverage the functionality of other advanced Microsoft applications. The Microsoft Office suite of products is a widely known and used bundle of software that can give you access to advanced features without doing a ton of extra coding.

One of the products in this suite is Outlook 2003. Known of course as mainly an email reader it also has a myriad of features and support for tasks, calendars, notes, contacts, meetings and more. When developing your own applications it is sometimes advantageous to take advantage of these features instead of trying to develop them yourself.

Note: This tutorial requires Visual Studio .NET running ASP.NET 1.1, however, the code provided can be implemented and translated into any language. The web form is simply an interface to exporting the vCalendar. Both VB.NET and C# code samples will be provided

Tech Note: This tutorial was tested with Outlook version 2003. The vCalendar may have different implementations within previous versions of Outlook and may require additional tweaking not provided by this tutorial. The assumption will be that you are running Outlook 2003

Read More

Working With Mobile ASP.NET Apps – Part 2

In part 1 of this tutorial we reviewed some basic concepts behind mobile development, we created a new mobile web application project and linked to a sample database and reviewed some of the principals behind mobile web forms.

In this second and final part of the series we’ll continue building upon our sample application and put an ObjectList control into practice using our sample data source.

We’ll also look at some of the mysteries behind this control that should help you avoid a lot of R&D and trial and error programming when it comes to rendering tabular data for mobile devices.

Note: Visual Studio .NET running ASP.NET 1.1 is required for this tutorial. Both VB.NET and C# code samples will be provided

ObjectList Confusion

In part 1 we reviewed the properties list of the ObjectList control and found that there were a plethora of properties available to use, yet finding complete documentation on the items is sometimes difficult. Even with the MSDN library itself the examples and explanations sometimes provide little or no help.

To compound the problem, online support and newsgroup discussions on the subject are somewhat scarce. It seems that mobile development is a bit of a hidden art, and you often have no choice but to simply figure things out on your own.

In this section we’ll cover some of the peculiarities of the ObjectList control that should help you avoid a lot of the common exceptions and errors encountered.

Read More

Working With Mobile ASP.NET Apps – Part 1

In the world of ASP.NET there’s a whole other breed of application that few developers ever have the need to work with: Mobile Web Applications. These are applications that are designed to run on mobile devices which can be anything from a pocket PC, to a BlackBerry, to a cell phone.

This realm of development is a very confusing one, due to the volume of disparate devices and their methods of implementation and visual capabilities. Often developers are left to focus on one particular style of device in order to bring out the best capabilities instead of taking a more generic one-size-fits-all implementation.

Because mobile development is so radically different in presentation the .NET framework has a dedicated set of assemblies for it residing in the System.Web.Mobile namespace. In this namespace is a dedicated set of interface components designed specifically to run on mobile devices, most of which duplicate the common components in regular web forms development such as labels, buttons, textboxes and so forth.

Although these components are fundamentally similar some of the principles behind mobile development are hidden and convoluted and developers are left spending many hours of trial and error getting certain basic features to work.

The goal of this two part tutorial is to review some of the not so obvious aspects of mobile development that often leave developers scratching theirs when finding solutions. We’ll implement a basic demonstration application that will take some of the common features performed in regular web development and see how they are implemented in a mobile development environment.

In part one we’ll setup a new mobile web application and connect it to a sample database so we have some data to work with and we’ll also review the DataGrid’s cousin in mobile development: The object list control. We’ll review some theory behind this control and some of its more confusing implementation designs and how best to use it and how not to use it.

In part two we’ll continue building on our demonstration application and implement a mobile form which uses the object list control and sub forms, and see how DataGrid style pages are developed in a mobile environment.

Note: Visual Studio .NET running ASP.NET 1.1 is required for this tutorial. We’ll also use the Northwind sample database which comes with SQL server as our test data source, or you may use any database of your choice for the purpose of demonstration

Read More

Using the .NET DataView Object

Using the .NET DataView Object

When building database driven web applications, presentation of data becomes a key component in your web forms. The common problem that arises is that no two users want to view their data the same way. One user wants to see only certain data; another user wants the data sorted by date ascending while another may only want to see data from the past week. The possibilities are literally endless.

As a developer, how do you cover all the scenarios? The answer is you really can’t, what you can do however is offer enough flexibility in data filtering to allow the user to customize their presentation themselves. And depending on what components you are implementing in your application, the DataView object is a good solution to provide this type of filtering.

In this tutorial we’ll look at a basic ASP.NET application that implements data column filtering as well as row state filtering. We’ll use a DataGrid component to search a column for data that matches a search pattern, thus filtering the user’s view. And we’ll also see how we can use the DataView to show only newly added rows; a pattern which can also be applied to edited or deleted rows easily.

We’ll need a sample database to work with so we’ll use the Northwind database which comes with all versions of SQL server, including MSDE. If you do not have access to SQL server you can simply link the tutorial example to any database of your choice and skip the database configuration section.

Note: Visual Studio .NET running ASP.NET 1.1 is required for this tutorial. Both VB.NET and C# code samples will be provided.

Read More

Securely Locking Down ASP.NET Web Services

Securely Locking Down ASP.NET Web Services

During this tutorial we will build 2 separate ASP.NET applications: One to implement the Web Service itself, and one to implement the consumer application which uses the Web Service. By having 2 applications we can effectively simulate the service/consumer pattern which would be found in a real world application, even though in our case both applications will be running on the same machine.

The demonstration Web Service will simply provide several test services which we can call from the consumer. The purpose behind these methods is not their functionality but rather to simply have something to execute. The focus of this tutorial is how to secure the service once it’s built.

We’ll then implement a consumer ASP.NET application and show how we can gain access to the Web Service even thought it’s been completely secured and locked down.

Note: Visual Studio .NET with ASP.NET 1.1 is required for this tutorial. Both VB.NET and C# code samples will be provided

Read More

ASP.NET DataSet Tips & Tricks

Technically part of the ADO.NET object library, the DataSet is one of the most fundamental and widely used data objects in the .NET framework. Used as an in-memory representation of database/XML data, it supports a plethora of handy methods, properties and contains various other object references for working with tables, rows, columns, relationships and more.

Because the DataSet supports so many features and contains so many references to other objects in the ADO.NET library, it can take quite some time to figure out just what is available to you as a developer when working with this object.

The DataSet object is also directly bindable as a data source on the various GUI components that support data binding. It works very nicely with the ASP.NET DataGrid object since both objects were designed to contain data in a similar tabular format.

In this tutorial we’ll focus on 3 key examples to explore some of the lesser known features of the DataSet object. The first example will be manual construction of a DataSet object from scratch. This example will get you familiar with the various object types that compose the DataSet object itself. By constructing the object from scratch you’ll have an idea of what happens when a DataSet is constructed from a database source.

The second example we’ll explore a handy object in ADO.NET that allows you to sort data in the DataSet object by using simple SQL like commands. We’ll build an example that sorts one of the columns of our DataSet from ascending to descending through auto-detection.

In the final example we’ll see how we can index our DataSet by creating a primary key, which then allows us to search through our DataSet for specific rows matching the values on the index we created.

Note: This example requires Visual Studio .NET with ASP.NET 1.1 capability. Both VB.NET and C# code samples will be provided

Read More

Dynamic Form Display with RadioButtonList

When developing user interfaces it’s often key to remember all the tricks and tools available to you so that you may combine them in creative ways in order to implement more advanced features. Given the sometimes limiting postback mechanism it’s important to make every refresh count, and to provide a unique experience by taking advantage of the postback server processing.

There are 2 particular server components that work together quite nicely to form a creative user interface experience: The RadioButtonList and the floating DIV tag. When combining these components we can create an almost wizard-like interface using some advanced GUI tricks in tandem with the postback events.

In this tutorial we will build an ASP.NET application with 2 dynamic pseudo “forms”, and we will then implement a RadioButtonList to simply flip between the 2 forms dynamically on the page. Although the forms will appear as layered on top of each other we’ll see how we can design the forms side-by-side in the design environment and then layer them together in server code.

By implementing AutoPostBack on the RadioButtonList we’ll show how we can create post backs and dynamically display the selected form to the user, creating a dynamic space in a small amount of screen space allowing for multiple entry screens without using the entire width and height of the page.

Note: This tutorial requires Visual Studio .NET and both VB.NET and C# code samples will be provided

Read More
Newer articles Older articles