9: Building a Content Management System in VS .NET

Create Code 3/9 in VS .NET 9: Building a Content Management System

9: Building a Content Management System
Make Barcode In .NET
Using Barcode creation for ASP.NET Control to generate, create barcode image in ASP.NET applications.
Figure 9-5: The Content List page
Code 39 Full ASCII Creator In C#.NET
Using Barcode creation for VS .NET Control to generate, create Code 39 image in .NET framework applications.
The Content Detail page
Code39 Generator In .NET
Using Barcode generator for .NET Control to generate, create Code 3 of 9 image in .NET framework applications.
Figure 9-6 shows the Content Detail page, which is displayed when the user selects one of the content items from the Content List page As you can see, each content item has just two elements: a title and text The Content Detail page simply displays the title and text for the item selected by the user Beneath the text are Edit and Delete links that let the user edit or delete the content item Like the Add link on the Content List page, these links are displayed only if the user has been assigned to the administrative role for the department The code-behind file for this page includes code that checks the user s role(s) and hides these links if the user is in a role that shouldn t see them If the user clicks the Delete link, the content item is summarily deleted and the Content List page is redisplayed But if the user clicks the Edit link, the page goes into Edit mode, as shown in Figure 9-7 Then the user can change the title or text to match the content item
Code 39 Generation In Visual Basic .NET
Using Barcode generation for Visual Studio .NET Control to generate, create Code 3 of 9 image in .NET framework applications.
Part V: Building Community Applications
Create Bar Code In Visual Studio .NET
Using Barcode generation for ASP.NET Control to generate, create barcode image in ASP.NET applications.
Figure 9-6: The Content Detail page
Make Barcode In .NET
Using Barcode maker for ASP.NET Control to generate, create barcode image in ASP.NET applications.
Figure 9-7: The Content Detail page in Edit mode
Bar Code Maker In Java
Using Barcode creation for Java Control to generate, create bar code image in Java applications.
9: Building a Content Management System
Generate EAN / UCC - 13 In .NET Framework
Using Barcode drawer for VS .NET Control to generate, create UCC-128 image in .NET applications.
Designing the Database
EAN 13 Generator In C#
Using Barcode generator for VS .NET Control to generate, create EAN-13 Supplement 5 image in .NET applications.
The Content Management System stores its content in a database named, appropriately enough, Content The Content database consists of just three tables: Departments ContentTypes ContentItems Figure 9-8 shows a diagram of this database, and the following sections describe each table individually
Paint Code-128 In Java
Using Barcode encoder for Java Control to generate, create Code-128 image in Java applications.
ContentItems contentid deptid typeid title [content]
Barcode Generator In C#
Using Barcode creation for .NET framework Control to generate, create barcode image in VS .NET applications.
Departments deptid name description
Scanning Barcode In Java
Using Barcode decoder for Java Control to read, scan read, scan image in Java applications.
Figure 9-8: A diagram of the Content database
GTIN - 13 Creator In VB.NET
Using Barcode drawer for .NET Control to generate, create EAN / UCC - 13 image in VS .NET applications.
ContentTypes typeid name
Generating Bar Code In .NET Framework
Using Barcode printer for .NET Control to generate, create bar code image in .NET framework applications.
The Departments table
UPC-A Supplement 2 Creator In Visual C#.NET
Using Barcode maker for Visual Studio .NET Control to generate, create UPC A image in .NET framework applications.
The Departments table stores the information about the departments represented in the Content Management System Table 9-1 lists the columns defined for this table
DataMatrix Generator In Visual C#.NET
Using Barcode encoder for .NET framework Control to generate, create Data Matrix image in .NET applications.
Part V: Building Community Applications Table 9-1
Paint GS1-128 In Visual Basic .NET
Using Barcode generator for VS .NET Control to generate, create UCC - 12 image in Visual Studio .NET applications.
Column name
Paint Bar Code In Java
Using Barcode maker for Java Control to generate, create barcode image in Java applications.
deptid
Code 128A Generation In Visual Basic .NET
Using Barcode encoder for VS .NET Control to generate, create Code 128B image in .NET framework applications.
The Departments Table
Bar Code Maker In Visual Basic .NET
Using Barcode creation for VS .NET Control to generate, create bar code image in .NET framework applications.
Type
VARCHAR(10)
Description
An alphanumeric code (up to 10 characters) that uniquely identifies each department This is the primary key for the Departments table The department name A short description of the department This text is displayed next to the department name on the Home page
name description
VARCHAR(255) VARCHAR(255)
The ContentTypes table
The ContentTypes table stores information about the different types of content that can be managed by the Content Management System Table 9-2 lists the columns defined for this table
Table 9-2
Column name
typeid
The ContentTypes Table
Type
VARCHAR(10)
Description
An alphanumeric code (up to 10 characters) that uniquely identifies each content type This is the primary key for the ContentTypes table The name of the content type
name
VARCHAR(255)
The ContentItems table
The ContentItems table stores the actual content that s managed by the Content Management System Its columns are listed in Table 9-3
9: Building a Content Management System Table 9-3
Column name
contentid
The ContentItems Table
Type
INT IDENTITY
Description
A column that uniquely identifies each content item This identity column is the primary key for the ContentItems table An alphanumeric code (up to 10 characters) that indicates which department this content item belongs to This is a foreign key An alphanumeric code (up to 10 characters) that indicates the content type This is a foreign key The title for this content item The text displayed for the content
deptid
VARCHAR(10)
typeid
VARCHAR(10)
title content
VARCHAR(255) TEXT
Creating the Database
On the CD that comes with this book, you ll find the script shown in Listing 9-1, which creates the Content database To run this script, open a commandprompt window and change to the directory that contains the script Then enter this command: sqlcmd -S localhost\SQLExpress -i CreateContentDBsql (I assume you re running SQL Server Express on your own computer If not, you ll need to change localhost\SQLExpress to the correct name)
Listing 9-1:
USE master GO
The CreateContentsDBsql script
1 2
IF EXISTS(SELECT * FROM sysdatabases WHERE name= Content ) DROP DATABASE Content
(continued)
Part V: Building Community Applications
Listing 9-1 (continued)
GO CREATE DATABASE Content ON (NAME=Product, FILENAME = C:\APPS\Contentmdf , SIZE=10 ) GO USE Content CREATE TABLE Departments ( deptid VARCHAR(10) name VARCHAR(255) description VARCHAR(255) PRIMARY KEY(deptid) ) GO NOT NULL, NOT NULL, NOT NULL,
4 5
CREATE TABLE ContentTypes ( typeid VARCHAR(10) NOT NULL, name VARCHAR(255) NOT NULL, PRIMARY KEY(typeid) ) GO CREATE TABLE ContentItems ( contentid INT IDENTITY, deptid VARCHAR(10) NOT typeid VARCHAR(10) NOT title VARCHAR(255) NOT content TEXT NOT PRIMARY KEY(contentid), FOREIGN KEY(deptid) REFERENCES FOREIGN KEY(typeid) REFERENCES ) GO
NULL, NULL, NULL, NULL, Departments(deptid), ContentTypes(typeid)
The following comments draw out the pertinent details of this listing:
1 2 3 4 5 6 7
Sets the database context to master Deletes the existing Content database if it exists Creates a database named Content, placing the database file C:\Apps Sets the database context to Content Creates the Departments table Creates the ContentTypes table Creates the ContentItems table
ALL RIGHTS RESERVED. Business Refinery (c) 2006 - 2010. Terms of Use | Privacy Policy