|
There are three main categories of applications you can create
for your web-based project: HTML only, Active Server Pages, and ASP.NET. This
also means that, in your applications, you may deal with various types of files.
You can create a complete application using a text
editor and IIS only or using a programming
environment.
|
You can use Microsoft Visual
Studio 2008 to create your application. Just as Notepad supports all these types
of applications, Microsoft Visual Studio 2008 also is completely equipped to
create, handle, and maintain HTML-only applications, Active Server Pages, or
ASP.NET. Everything will depend on what you are trying to do as long as you know
that the choice is yours.
An HTML-based application is a web-based project that mostly
includes regular pages with HTML tags, optional Cascading Style Sheet
formatting, and optional scripts to perform some tasks that are difficult or
impossible with only HTML.
You can also use other formatting languages like XML to support
some type of data in your application but an HTML-based application is primarily
meant to use HTML tags to present text and graphics to a visitor. With this type
of application, you usually don't expect any back-and-forth interaction between
the visitor and you.
To create an HTML-based application, there is no special thing
to do in Microsoft Visual Studio because the structure of this type of
application lies on its use of web-oriented files. There are only two primary
requirements. To start, you must create a folder with a name of your choice. You
can create this folder using a utility such as Windows Explorer or My Computer.
If you want, you can also use Microsoft Visual Studio 2008 to create this
folder. To do this, you can create an ASP.NET
Application. This would prompt you to accept the suggested name of the folder or
to give a new name of a folder.
The string you accept or provide on the left side of the Browse
button would be the folder that contains your web application. Once you click
OK, Microsoft Visual Studio 2008 would create the folder for you and get it
ready to receive your files.
After creating the folder of your web-based application, you can
create the necessary files for it. The most regularly used files are text-based
but they have the .htm or .html extension. This type of file is called an HTML
file. You can create the file using Notepad. Otherwise, if you had created the
folder using Windows Explorer or My Computer, to create an HTML file in
Microsoft Visual Studio 2008, on the main menu, you can click File -> New ->
File... In the Templates list of the New File dialog box, you can click HTML
Page. In the Name text box, accept or change the suggested name of the file. You
can include the .htm extension but if you don't, it would be added for you:
Once you are ready, you can click Add. A web page would some
skeleton code would be created for you. You can start writing in it and
populating it as you see fit. To manually edit the file's code, in the bar under
the page, you can click the Source button and edit the existing code. At any
time, to save the file, on the main menu, you can click File -> Save, locate the
folder you created for your web site and save the file.
If you had created an ASP.NET Application using Microsoft Visual
Studio 2008 and you want to add a new HTML file to it, on the main menu, you can
click Web Site -> Add New Item... In the Add New Item dialog box, make sure that
HTML Page is selected. Accept the suggested or change it. Once you are ready,
you can click Add. A new file with .htm extension would be added to your
project.
The difference between an ASP file you create using a Text File
and and you create using Microsoft Visual Studio 2008 is that you can design the
latter. This means that, after creating an ASP file in Microsot Visual Studio,
you can click the Design button in the bottom section, and use the HTML button
on the Toolbox to populate the web page.
Active Server Pages Applications
|
|
At one time, Microsoft developed Active Server Pages, which was
a technique of using Microsoft Internet Information Server (4.0) and scripting
languages such as VBScript or JavaScript to create interactive web pages, more
structured that traditional HTML files. An Active Server Pages application is a
web site that includes HTML and optional files that have an .asp extension. In
fact, the essence of an ASP-based application is to have at least one file with
that extension.
You can create an Active Server Pages application without using
any formal programming environment. To start, you should create a folder that
would hold the files of your application. You can use Windows Explorer or My
Computer to do this. After creating the necessary folder for your project or the
ASP.NET Application, you can create the necessary files. The next non-required
step for an ASP application consists of creating a simple text-based file named
Global and that has the .asax extension (Global.asax). This file
would be used later on to process files at the application level.
In Microsoft Visual Studio 6.0, to support Active Server Pages,
Microsoft created Visual Interdev. The Visual Interdev development environment
is the ancestor of ASP.NET. To create an Active Server Pages application using
Microsoft Visual Studio 2008, you can create an ASP.NET Application, give it a
name and click Open. To add a Global.asax file to it, on the main menu, you can
click Web Site -> Add New Item... In the Templates list, click Global
Application Class and accept the suggested name of the file:
Once you are ready, you can click Add.
Besides HTML files, css files, and/or script-based files we
mentioned for an HTML-based application, you can add special active pages. An
Active Server Pages file, also called an ASP file, is a text-based document that
has the .asp extension. You can use Notepad to create the file as long as you
remember to add the .asp extension when you decide to save it. To create an ASP
file, if you had created the folder for your application, in Microsoft Visual
Studio 2008, on the main menu, you can click Web Site -> Add New Item (or File
-> New -> File...) In the Templates section of the New File dialog box, you can
click Text File. To make it an ASP file, when specifying the name of the file,
type the name of the file and include the .asp extension:
Once you click Add, a new, but empty, ASP file would be added to
the folder you selected.
After the ASP web page has been created, you can design it using
the controls from the HTML section of the Toolbox.
An ASP.NET project is an enhanced version of an Active Server
Pages application and you can create it using Notepad. As we saw earlier with
IIS, to start, you would create a folder that can hold the files of your
application. You can then add the necessary files. If you exclusively use
Notepad, you would (manually) type all your code. This is why Microsoft Visual
Studio 2008 can be very helpful.
Besides ASP.NET own files, you can also create ASP, HTML,
CSS,
and other script related files to add to your ASP.NET application.
Using Microsoft Visual Web Developer 2008
|
|
Notepad's simplicity is well suited if you are just writing
code. If you are developing a graphically intensive application, Notepad
presents some limitations because everything would have to be typed (manually).
To accelerate ASP.NET application development, Microsoft provided complete
support in Microsoft Visual Studio 2008. This environment allows you to create
an application and have a better view of where items are positioned on the web
page. This can be a tremendous help if your application includes "graphical"
controls.
Besides Microsoft Visual Studio 2008, you can download and use
Microsoft Visual Web Developer 2008 Express Edition. To get it, go to the
Microsoft web site and look for Visual Studio Express or Visual Studio Express
Editions. Once on the page, locate Microsoft Visual Web Developer 2008, select
your language, and click Download:
When the download starts, click Run. The Setup will start. Then
you will be presented with the first page of a wizard:
You can click Next and follow the instructions. Make sure you
accept to install Microsoft SQL Server.
The install will start and it can take a while. When the
installation is over, you will be asked to register the product within 30 days:
Which you should do.
The techniques we introduced above, including creating a folder,
a virtual directory, and the necessary file(s) require that you follow those
steps to get the project ready. This is perfectly fine if you have time to
create and write all necessary tags required in a web page. To make it a little
easier, there are various tools you can use to visually design your ASP.NET web
pages.
Microsoft Visual Web Developer 2008 Express Edition is a
programming environment that allows you to create an ASP.NET application as a
project.
Creating an ASP.NET Project
|
|
The lessons on this site assume that you have Microsoft Visual
Web Developer 2008 Express Edition installed in your computer. To start
Microsoft Visual Web Developer 2008 Express Edition, on the Taskbar, you can
click Start (All) Programs -> Microsoft Visual Web Developer 2008 Express
Edition
To create an ASP.NET application in Microsoft Visual Web
Developer 2008 Express Edition, on the main menu, you can click File -> New Web
Site... In the New Web Site dialog box, make sure ASP.NET Web Site is selected.
In the Language combo box, select Visual Basic. Specify a name and location in the
combo box on the left side of the Browse button or click the Browse button to
specify a folder:
Once you are ready, click OK. Microsoft Visual Developer 2008
Express Edition would create the necessary starting folders and files.
In the Microsoft Visual Studio interface, some windows are
represented with an icon that hides the rest of the body. An example is the
Toolbox button (by default positioned on the left side of the interface:
To display such a window, you can position the mouse on it.
This would expand the window:
If you expand a window, it would display a title bar with three
buttons. One is called Auto Hide and the other is the classic Close button.
If you expand a window but find out you don't need it any more,
you can just move the mouse away from it. The window would return to its
previous state. Based on this functionality, if you are working with a window
and move the mouse away from it, it would retract. If you need it again, you
would have to reopen it using the same technique. If you are going to work with
a certain window for a while, you can keep it open even if you move the mouse
away. To do this, click the Auto Hide button
.
If clicked, the Auto Hide button changes from pointing left to pointing down
.
When Microsoft Visual Web Developer 2008 Express Edition opens,
it makes some windows necessary. These are the most regularly used windows. If
you think that one of them is not usually used in your types of assignments, you
can remove it from the screen by clicking its Close button. All of the windows
you can use are listed in the View menu. Therefore, if a window is not
displaying, you can click View on the main menu and click a window of your
choice.
By its default installation, Microsoft Visual Web Developer 2008
Express Edition installs some windows to the left and some others to the right
of the screen. You can change this arrangement if you want. To do this, expand a
window, then drag its title bar to another location on the screen. Windows can
then be "coupled", that is, docked together to one side of the screen. When
windows are grouped, they automatically create tabs, allowing you to select the
desired one by clicking its tab.
The options available in windows display differently depending
on the window and the items in it. Some item are organized in a tree list
equipped with + or – buttons. To expand a list, you can click its + button. To
collapse a list, click its – sign. Some other items appear as button.
Compiling and Executing a Project
|
|
The instructions created for an ASP.NET project are written in
plain text including HTML tags and script sections. In previous ASP
applications, the code simply had to be interpreted by the browser. With
ASP.NET, you must compile the project.
To compile and execute an ASP.NET project in one step, on the
main menu, you can click Debug -> Start Without Debugging. Although there are
other techniques or details in compiling (or debugging) and executing a project,
for now, this is the technique we will use.
As opposed to creating a new project, you can open a project
that either you or someone else created.
To open an existing project:
- If you had just created or used a web site, in the Start Page, if you see its
name, you can click it
- If you had just previously used the project, on the main menu, you can click
File -> Recent Projects and click the project in the list displayed
- If the project is not in the list of Recent Projects under the File main menu
but you know that it exists, on the main menu, you can click File -> Open Web
Site... The action would display the Open Web Site dialog box. By default, each
ASP.NET application you create receives a new folder in your local Drive:\Documents
and Settings\Usernane\My Documents\Visual Studio 2008\Projects
folder (an additional folder is created in Drive:\Documents and Settings\Usernane\My
Documents\Visual Studio 2008\Web Sites). When opening an ASP.NET project, if
you don't know where it is located, you should first navigate to this folder.
Once you have located the folder that contains the project, select the folder
and click Open