rss feed blog search engine
 
Search rss blog search engine
 
Primary Objects Sitemap Articles  
Released:  10/3/2006 10:42:14 AM
RSS Link:  http://www.primaryobjects.com/rss/Sitemap_Articles.xml
Last View 9/6/2008 8:50:39 AM
Last Refresh 9/6/2008 7:24:42 PM
Page Views 1839
Comments:  Read user comments (0)
Save It Add to Technorati Add to Del.icio.us Add to Furl Add to Yahoo My Web 2.0 Add to My MSN Add to Google Add to My Yahoo! Primary Objects Sitemap Articles



Description:



Primary Objects Sitemap Articles


Contents:

Three Ways to Bind a DropDownList with LINQ and C# ASP .NET
 

Introduction

With the latest release of C# ASP .NET 3.5, Visual Studio 2008, and LINQ, there is a whole new way of working with the data layer in C# ASP .NET web applications. Prior to LINQ, many developers would either generate or custom-code a data layer based upon the usage of SqlConnection, SqlCommand, and DataReader objects to manipulate data. With LINQ and LINQ to SQL, we no longer need to rely on the details of the connection objects and can instead begin thinking more abstractly by using the pre-generated LINQ business objects and the data access layer. In this manner, LINQ has brought a conformity to the data layer in ASP .NET web applications. However, as with any new technology, new architectures often arise to support them. As we continue on, you'll see how to implement your own tiered architecture, specifically for populating datasource controls.

In this article, we'll visit three ways to populate a DropDownList control by binding to a data source. W ....


Writing a Simple Role Playing Game with C# .NET and the State Design Pattern
 

Introduction

The State Pattern is an interesting design pattern in that it allows us to separate out portions of code into individual related modules, or states. This pattern is particularly useful for applications which need to retain state information, such as the current phase a program is in. While you can typically maintain this information using a basic integer variable, the State pattern helps abstract the specific state logic, reduces code complexity, and greatly increases code readability. This can make the difference between an application maintenance nightmare and a work of art.

This article describes how to use the State Pattern with C# to create a simple, console-based RPG role playing game. You'll be able to see exactly how the State pattern fits into the flow of the rpg game and how it easily cleans up the code, in what might typically be a confusion of integer values and if-then statements.

 Preventing Session Timeouts in C# ASP .NET
 

Introduction

C# ASP .NET has a setting in the web.config file which allows selecting the desired session timeout. When the session timeout value expires, the currently logged in user's session is deleted and the user is directed back to the login page. The default timeout value usually hovers around 20 minutes for ASP .NET's session timeout. While this is the expected behavior, often clients may require the session timeout to be increased dramatically or even avoid any timeout at all while the user is logged in.

This article describes a solution for web applications which require a session to never timeout or for those who have a session timeout occurring before the value set in the web.config. The solution is invisible and seamless and has been tested in Internet Explorer, Firefox, and Safari.

 

Why Would a Client Want No Session Timeout?

A typical scenerio where a user may want to ....


Using the Iterator Pattern in C# ASP .NET
 

Introduction

The Iterator design pattern provides us with a common method of enumerating a list of items or array, while hiding the details of the list's implementation. This provides a cleaner use of the array object and hides unneccessary information from the client, ultimately leading to better code-reuse, enhanced maintainability, and fewer bugs. The iterator pattern can enumerate the list of items regardless of their actual storage type.

The Iterator design pattern is actually a quite common pattern in most object oriented programming languages, especially in C# and Java. In fact, both languages include their own pre-built Iterator pattern, which can be inherited from. Of course, knowing how to create your own Iterator design pattern can provide great benefits and allow you to expand your design when needed.

This article will describe three ways to traverse a list of items, from simply walking the array, to using the built-in C# ASP .NET IEnumerable in ....


A C# .NET Adventure Game Simulator and the Strategy Pattern
 

Introduction

The strategy design pattern is a useful pattern for pulling out frequently changing pieces of code and encapsulating them within individual classes. The strategy pattern allows us to reference these new classes in a loosely-coupled fashion, without directly referencing the concrete implementations. This gives us the powerful ability of choosing concrete classes dynamically at runtime, instead of hard-wiring them during code design. This article will show an example usage of the strategy design pattern in creating a basic RPG-style adventure game simulator. The idea for the simulator comes from the popular book Head First Design Patterns by O'Reilly.

 

Game Design

In this particular game design, we will have specific types of characters and weapons. This directly leads to two basic classes: Character and Weapon. All characters will inherit from an abstract Character class, which w ....


Using the Model View Controller Pattern in C# ASP .NET Web Applications
 

Introduction

With the release of Visual Studio 2008, Microsoft is working on including an add-on for C# ASP .NET web application developers to include the Model view Controller (MVC) design pattern within their software architecture. While one of the add-on's core purposes is to enhance URL functionality in a web application by enabling a model view controller pattern and design structure, the MVC design pattern itself, can be a powerful tool in your C# ASP .NET web applications.

 

What is the Model View Controller Design Pattern?

The Model View Controller (MVC) design pattern lets us pair loosley-coupled Models and Views together. In this manner, we can keep view logic completely separate from model logic. We can then interchange views or models with different classes, effectively changing an ASP .NET web application's functionality with minimal side-effects.

Since this description ....


Implementing a Database Factory Pattern in C# ASP .NET
 

Introduction

Designing a C# ASP .NET web application which utilizes a database is a common and straight-forward task for developers. The web application accesses various tables, stored procedures, executes SQL script, and retrieves records. Often, developers not familiar with design patterns will use a simple design for making database calls, which relies on calling database functions straight from the user interface. While this certainly works (and provided you close and dispose of all connections when you're done with them), you achieve a far greater amount of flexibility with your C# ASP .NET web application be using a well-defined and loosely-coupled database layer.

 

Why Do I Need a Database Layer Anyway?

When creating software for clients, even the beginner developer recognizes the frequency of change. Requirements change, user interface pieces change, platforms change, and databases ch ....


Using the Memento Design Pattern in C# ASP .NET
 

Introduction

The Memento design pattern is a useful pattern in C# ASP .NET for saving the state of an object for retrieval at a later time. A common example of the Memento pattern would be the Undo command of various programs. With the Undo command, the current state information for the task at hand is saved (such as in a Memento). The user may continue modifying data. Upon invoking the Undo command, the state of the data is restored back to its previous state (as stored within the Memento). This article describes how to implement the Memento design pattern in a C# ASP .NET web application. Specifically, this version of the Memento pattern will allow saving multiple types of class states within a single memento object.

 

Why Not Just Code it the Basic Way?

If you're familiar with implementing state-saving functionality, such as the Undo command, in C# ASP .NET web applications, you may be have ....


Passing Arrays to SQL Stored Procedures in C# ASP .NET
 

Introduction

Stored procedures provide a powerful extension to C# ASP .NET by allowing us to move large portions of data manipulation logic to the database server. Stored procedures are optimized to process data and their associated logic faster than the application layer and are therefore the preferred layer for database logic processing in .NET applications. While stored procedures can be designed to accept many different kinds of parameters as input, it's only a matter of time before you have a need to pass a C# .NET array or collection as an input parameter.

This article explains a simple method for passing an array from your C# ASP .NET application to an MSSQL stored procedure by using a bit of dyanmic SQL.

 

MSSQL Limitations and Arrays

MSSQL is a favorite database platform for C# ASP .NET developers. For the most part, MSSQL has everything you need for your application. However, o ....


Using the Microsoft Message Queue MSMQ and C# ASP .NET
 

Introduction

There are several different kinds of queues available in the C# ASP .NET framework with the most popular one being the standard Queue collection object. While these collections are easy to work with and fairly robust they are still stored in memory and therefore temporary. Often, in enterprise application design, more stringent means of managing and storing temporary data are required.

In the case of receiving timely data to be processed, using a queue in your software design makes sense. When the data needs to be guaranteed for delivery and protected from loss, the Microsoft Message Queue MSMQ provides a scalable easy solution.

 

At its core, Microsoft Message Queue MSMQ is a queue collection with a persistent storage backing. This means that data sent to the queue is automatically persisted within an internal Windows database. The MSMQ is also thread-safe, which means a multi-threaded C# ASP .NET application may safely send and receive me ....


Exporting XML in a C# ASP .NET Web Application
 

Introduction

XML (extensible markup language) is a popular format of data for importing and exporting between different applications designed using different programming languages. Since XML uses a standardized format of data, applications can easily parse the XML data to pull out specific fields, blocks, and even write their own XML files. XML is especially useful as a protocol for communicating over the Internet with applications (ie. SOAP). Given the flexibility of XML, it's only a matter of time before your own C# ASP .NET web application may need the ability to import or export XML data to another application.

 

Distorted HTML

At a first glance, XML looks just like a web page in HTML. You can easily recognize beginning and ending tags. Brackets enclose each element's name. The document usually has a header tag and a final closing tag. This makes using XML in a C# ASP .NET web appl ....


Designing Software with Generics and Reflection in C# ASP .NET
 

Introduction

As software becomes more complex, the ability to design a modular and re-usable architecture into your software becomes increasingly important. Using the programming concept of generics with interfaces, included in C# ASP .NET 2.0, software developers can abstract algorithms and classes into individual class libraries. The libraries can be accessed, in a generic fashion, from the main software. The key to this process relies on using interface design patterns and .NET reflection.

 

What's a Generic?

.NET generics can cover several related topics. The common usage of generics is specifying templated object names instead of concrete ones, which lets you pass multiple types to a function rather than only the concrete form. However, in the example listed below, we will be focusing on using generics and reflection with a class library interface architecture. This is becoming a pop ....


Using the Observer Design Pattern in C# ASP .NET
 

Introduction

Similar in nature to the Chain of Responsibility design pattern, the Observer pattern allows linking of several listener classes to a subject class. When a change or event occurs within the subject class, all listeners are made aware of the event and may take action. This essentially creates a one-to-many relationship between the subject and listeners and can be a powerful tool when designing your software with C#.

 

Differences Between the Chain of Responsiblity and the Observer

The Chain of Responsibility pattern and the Observer pattern are similar in that they both provide a means of allowing multiple classes to handle an event. The Chain of Responsibility typically passes the event down the chain and once the event is handled, the chain ends. This results in a single class acting upon the event. In contrast, the Observer pattern passes the event to all listeners in the chain, wh ....


Applying Chain of Responsibility Design Patterns in C# ASP .NET
 

Introduction

A powerful design pattern geared towards handling an event is the Chain of Responsbility design pattern. This pattern helps decouple related algorithms in C# ASP .NET and can help your software become more scalable and easier to control.

In general, the Chain of Responsbility design pattern allows you to link together a serious of classes or algorithms in a hierarchy and pass a command (preferably a Command pattern object) into the mix to get handled by one of the members of the chain. One of the benefits of this design pattern is, not having to know the details of the members in the chain. You simply pass the command into the chain. Each class will attempt to handle the request until all classes have been used. While it is possible for a request to go unhandled, this is a powerful design pattern when used appropriately.

 

Two Ways to Make a Chain

As with all first prog ....


Using the Command Object Design Pattern in C# ASP .NET
 

Introduction

The Command Object design pattern can be a powerful tool to use in development of C# ASP .NET web applications. The Command design pattern brings object oriented design to an otherwise non-object oriented piece of data - a command.

It is common to create classes and functions which operate by accepting a command to perform. The command may be a simple string of text or a globally defined integer. In both cases, this command is typically acted upon and then discarded. By wrapping a basic command within a Command Object design pattern, .NET applications can take advantage of the power to perform additional processing on the Command object, log commands, add additional parameters, and much more.

 

What's Wrong with an Integer Command?

The basic method for issuing a command to a class or function is by assigning a global unique integer to be a dedicated command message. The functi ....


Using Microsoft Silverlight to Fade an HTML Form
 

Introduction

Microsoft has recently released the beta version of Silverlight. For those unfamiliar with what Silverlight is, it is essentially a plug-in technology to create web pages and web applications that look much closer to desktop applications. It appears to combine the best of AJAX, DHTML, and Flash/applet technologies by providing stunning visual graphics, animations, programmability, and .NET integration that is compatible with many different web browsers. In a nutshell, it runs .NET in your web browser.

Silverlight is expected to include its own SDK of built-in graphical controls (buttons, drop-down lists, grids, etc). However, this article touches the very beginning of using Silverlight with standard HTML controls; using it more as a replacement for Ajax and DHTML to enhance a standard web page, rather than taking over the entire HTML screen with animated graphics.

 

Fading an HTML Form ....


The Strategy Design Pattern in C# ASP .NET
 

Introduction

Developing software can quickly become a complicated process, with lists of funtions, procedures, loops, and repetitive code. Understanding theories of design patterns and implementing them, when neccessary, can help simplify a software's design.

Design patterns have been around for many years, but have recently began gaining popularity due, in part, to Microsoft's promotion of design patterns with the C# .NET framework. If you take a look throughout the .NET framework, you'll recognize many design patterns already existing. In fact, you use them every day in your C# ASP .NET coding, probably without realizing it.

For those who are new to design patterns, the Strategy pattern can be a very handy tool in your C# ASP .NET software design. To describe how to implement the Strategy design pattern, we'll start with the typical "Hello World" Stratgey design pattern.

 

What's ....


How to Kill MySQL Sleeping Connections in C# ASP .NET
 

Introduction

MySQL is a free database included with many web hosting services on linux and Windows platforms. C# ASP .NET developers, using a MySQL database back-end, may notice an unnecessarily large list of sleeping connections that remain online in MySqlAdministrator. This can cause wasteful use of memory on the server, degrade performance, and ultimately, create an error in your C# .NET web application. For example, if you go over the limit set by the database administrator for number of connections, your application will receive a "Too Many Connections" error in MySQL. This can cause your application to fail to display data, fail to load pages, or just freeze up on users viewing the .NET site.

 

Too Many MySQL Connections

Open MySqlAdministrator, click on the Server Connections link, and view the active Threads. Web-based ASP .NET applications seem to incorrectly ha ....


Connecting to a MySQL Database with C# ASP .NET
 

Introduction

If you're creating a web application using C# ASP .NET, you will more than likely be using one of the three top database engines MySQL, MSSQL (Microsoft SQL Server), or Oracle to store your online data. From the developer's view, all three databases are virtually the same. You use the same generic framework calls to connect, read, and write data. While it is more common to use Microsoft's MSSQL Server with a .NET application, a large number of web hosts offer the free MySQL database. Therefore, connecting to a MySQL database from C# ASP .NET is an important task and is actually quite easy to do.

 

Using MySQL with C# ASP .NET

MySQL is a free database and is used very heavily by the linux developers usually when programming with Perl, CGI, or Ruby on Rails. Because of this, MySQL is, for the most part, catered and optimized directly towards the linux developing platform. However, using MySQL from a Windows web application is also supported a ....


Creating XML RSS Feeds with C# ASP .NET
 

Introduction

An RSS feed is really just a fancy term for an XML file, specifically used to re-distribute web content to aggregators. The most commonly used form of an RSS feed comes from blogs, which are constantly increasing in popularity. Combine the interest in blogs with the major web browsers' ability to now aggregate RSS feeds, and you have a very prominent reason to start creating RSS feeds in your C# ASP .NET web application.

 

Atom vs RSS

There are actually two types of popular feeds, Atom and RSS. Atom feeds are a more reader-friendly format of XML, and typically display in the web browser in a readable format by simply navigating to the feed.xml URL. RSS feeds, on the other hand, are meant as a more stripped-down version of XML, more easily parsed by aggregators. When viewing an RSS XML feed in your web browser, you will see a list of data tree branches, where you can shrink and expand the XML sections. Internet Explorer 7.0 and Firefox have ....


Resetting Passwords in Active Directory with C# ASP .NET
 

Introduction

One of the most common functions to perform in Active Directory from a desktop application or C# ASP .NET application is resetting user passwords. Due to the security features of Windows, resetting a password can be a little tricker than you think. After throwing in the security features of IIS and Windows Server, changing passwords from a web application seems almost impossible. However, by following a few important guidelines, you can have your web application easily resetting user passwords in Active Directory.

Note, if you are not yet familiar with connecting to Active Directory in C# .NET, please read our article on Using Active Directory with C# .NET.

 

Resetting a Password vs. Changing a Password

Active Directory makes a distinct difference between resetting a user's password and changing it.

Resetting a user's password is an administrative function and does n ....


Fixing: VC Package not available or not registered
    

Introduction

Recently, an error occured on a PC with both Visual Studio .NET 2003 and Visual Studio 2005 installed, where new forms could no longer be added to a web project and new projects could not longer be created in VS2003. Upon trying to perform either task, an error message would display stating: "VC Package not available or not registered".

VC Package not available or not registered 

 

Microsoft's web site offers a solution which involves using the Visual Studio 2003 installation CD-ROM and issuing a repair via the control panel. They state the error occurs because the Windows Installer is not registering the TLB and DLL files as they already exist. Issuing a repair re-registers the proper DLL files needed for Visual Studio 2003 to run properly. Microsoft states the steps to correct this are as follows:

Microsoft's Solution



Home  
 


Link to us




RSS Feed of new blogs                                                   Home        Feed Map        Submit Feed      Link to Us       Contact