ASP 101 - Active Server Pages 101 - Web05
The Place ASP Developers Go!

Please visit our partners


Windows Technology Windows Technology
15 Seconds
4GuysFromRolla.com
ASP 101
ASP Wire
VB Forums
VB Wire
WinDrivers.com
internet.commerce internet.commerce
Partners & Affiliates














ASP 101 is an
internet.com site
ASP 101 is an internet.com site
IT
Developer
Internet News
Small Business
Personal Technology

Search internet.com
Advertise
Corporate Info
Newsletters
Tech Jobs
E-mail Offers

ASP 101 News Flash ASP 101 News Flash



 Top ASP 101 Stories Top ASP 101 Stories
VBScript Classes: Part 1 of N
Migrating to ASP.NET
Getting Scripts to Run on a Schedule

QUICK TIP:
Basic Debugging in Classic ASP
Show All Tips >>
ASP 101 RSS Feed ASP 101 Updates


The Value of .NET Server Controls in Content Management

by Bill Rogers, Founder and CEO, Ektron, Inc.

Introduction

Server controls are just one of the many developments in content management solutions. Their power cannot be overstated for developers to be more efficient than ever before.

Microsoft .NET and server controls as an integral part of Microsoft's .NET strategy, allow Web developers to create applications much more easily. Using techniques such as drag and drop a developer can quickly perform functions that previously required extensive coding. While Microsoft offers a library of server controls, developers and software suppliers are also able to create their own, thus encapsulating frequently used functions for re-use elsewhere. A large number of third-party server controls now exist, providing a wide range of off-the-shelf functions for the developer to tap into.

With the introduction of ASP.NET and Visual Studio NET, Microsoft has caused a paradigm shift in the way Web applications are created and developed. Instead of developing linear code, interspersed with HTML, the developer can now create a Web application by selecting controls from a toolbox and placing them in a page. Controls are then connected where necessary by setting properties or, if the application warrants, by writing code to set their properties.

The result is a programming environment for Web-based client server applications similar to that which Visual Basic provides for conventional client-side applications. Indeed many of the controls are exactly the same. And while there are still many differences between the environments, Microsoft has successfully achieved what they set out to do: to superimpose a conventional object-based programming environment on top of HTTP and a client server framework.

The Visual Studio Web Form corresponds to a Web page in the application and acts as a container in which various server controls are placed. Each control comes with a set of properties that can be set directly within Visual Studio or by code statements. Code is held separately and written as a set of event procedures and is held in a separate file which is maintained by Visual Studio and referred to as Code Behind.

By deploying these controls into a Web Form, the application can contain dynamic content and other elements which are managed by a content management solution (CMS) giving access to workflow, content, navigation functions, multiple languages and other powerful features.

Some Examples

To illustrate how server controls work, let's look at couple of basic examples: One of the simplest controls in a CMS is the login control. To create a page or template for logging into a CMS, the developer simply drags a single server control from the Visual Studio toolbox and places it into the Web form. If additional elements are needed they are added and the login page is done.

Another example is to add a content block, a section of managed HTML, to a page. The developer drags in the content block server control and places it on the page. The CMS Explorer dialog allows the developer to browse through the content managed by the CMS and select a content block. The server control is linked to the application database from within Visual Studio.

The result is that to select a content block ID the developer can browse the folder structure of the real application database, even if it is located on a different server. Once the content block ID has been selected, the content from the database is rendered into the Web Form. As a result the developer gets to see what the final page will look like all from within Visual Studio. No more time-consuming toggling from one environment to another.

To enable the content block to use a dynamic reference, the developer simply sets the dynamic content variable property to the name of the variable that is used to pass the content ID. The content block control will find a URL variable containing a content block ID number and display the requested HTML. The URL variable can be masked for vanity URL's by using the CMS URL alias feature. In a more complex template the developer can use code behind to execute statements that assign a value to the content block's content ID property.

The server controls can return a dynamic list of managed content objects. The collection function, for example, returns a list of quick links that form the basis of a navigation bar. The list summary returns a similar list that might be used for recent news items. The results of a search function take much the same form of a list, returning pages that contain a match.

Most of the server controls have a default mechanism for displaying these results, for example the list summary function can be set to display the page titles only, or the page titles along with the page summary and last modified date. The title will be rendered as a link to the page itself. This is useful, for example, if you want a list of news articles where each title in the list links to the complete article. But what if you want a more sophisticated display? What happens if a list includes 100 items and you want to paginate them?

In the "old days," a developer would have to write code to count off the number of items, format them in an HTML table with Next Page, Previous Page, First and Last page buttons; code to check the page ranges; code to handle the buttons presses, etc. Even an experienced programmer could spend half a day or more getting this to work correctly.

Using the DataGrid server control and an ASP.NET technology called data binding all of this can be achieved with a few mouse clicks and one line of code. The DataGrid, one of the standard controls available in Visual Studio, is a sort of intelligent table function. It presents tabular data from a data source. It has properties to point to a data source and to set the form of the display, such as color, font, background image etc. A couple of the more interesting properties include pagination of the display, and data sorting using one of the bound variables as the key.

In our simple example to list new articles, we can create a Web Form, drag and drop a list summary control and a DataGrid control. Since we are not using the list summary to display results, we set its 'visible' property to false. Next, we set its folder property to point to the folder whose contents we want to index (in this case the news folder.) In the DataGrid control we set the data source property to point to the list summary control. Finally we set the 'Paginate' property to true and, if we want sorted results, we set the DataGrid to sort using date or publication as the key. Since data binding takes place at runtime we must insert one line of code in the page load event for the Web Form.

It would take a developer longer to read the previous paragraph than it would to program the page. In a matter of seconds, a developer can create a page with a list of news articles sorted into date order and presented with pagination in an index page with the titles forming links to the articles.

Data binding is a powerful technique supported by a number of the standard server controls. For more refined control over the HTML formatting of data bound content Microsoft provides the DataList and Repeater controls. It is also possible to populate drop-down lists controls or option lists from data bound sources. To complement this data display capability, many server controls can act as a data source (ie: List Index, Collection, etc.) Another interesting possibility is to bind data from an XML content block into a display control, using the DataGrid control to present XML data in tabular form. With this approach, developers can bypass the need to develop tricky XSLTs.

Conclusion

Microsoft .NET represents a step forward in programming Web applications, providing an object-based programming model for handling client server applications.

Today, developers of content-driven Web sites can tap into CMS functions -- effectively and efficiently. As a result, organizations can dramatically reduce the amount of time required to develop Web applications.


Home |  News |  Samples |  Articles |  Lessons |  Resources |  Forum |  Links |  Search |  Feedback


The Network for Technology Professionals

Search:

About Internet.com

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers