Asp intro !! Active Server Pages (ASPs) are Web pages that contain server-side scripts in addition to the usual mixture of text and HTML (Hypertext Markup Language) tags. Server-side scripts are special commands you put in Web pages that are processed before the pages are sent from your Personal Web Server to the Web browser of someone who's visiting your Web site. When you type a URL in the Address box or click a link on a Web page, you're asking a Web server on a computer somewhere to send a file to the Web browser (sometimes called a "client") on your computer. If that file is a normal HTML file, it looks exactly the same when your Web browser receives it as it did before the Web server sent it. After receiving the file, your Web browser displays its contents as a combination of text, images, and sounds.
In the case of an Active Server Page, the process is similar, except there's an extra processing step that takes place just before the Web server sends the file. Before the Web server sends the Active Server Page to the Web browser, it runs all server-side scripts contained in the page. Some of these scripts display the current date, time, and other information. Others process information the user has just typed into a form, such as a page in the Web site's guestbook.
To distinguish them from normal HTML pages, Active Server Pages are given the ".asp" extension.
What Can You Do with Active Server Pages?
There are many things you can do with Active Server Pages. You can display date, time, and other information in different ways. You can make a survey form and ask people who visit your site to fill it out, send emails, save the information to a file, etc.
What Do Active Server Pages Look Like?
The appearance of an Active Server Page depends on who or what is viewing it. To the Web browser that receives it, an Active Server Page looks just like a normal HTML page. If a visitor to your Web site views the source code of an Active Server Page, that's what they see: a normal HTML page. However, the file located in the server looks very different. In addition to text and HTML tags, you also see server-side scripts. This is what the Active Server Page looks like to the Web server before it is processed and sent in response to a request.
What Do Server-Side Scripts Look Like?
Server-side scripts look a lot like HTML tags. However, instead of starting and ending with lesser-than ( < ) and greater-than ( > ) brackets, they typically start with <% and end with %>. The <% is called an opening tag, and the %> is called a closing tag. In between these tags are the server-side scripts. You can insert server-side scripts anywhere in your Web page -- even inside HTML tags.
Displaying the Current Date and Time -on asp
The date and time described in this section are those that are on the server.
Date
To display the current date by itself in a Web page, type:
<% =date %>
at the point where you want it to appear. When you view the page in your browser, you should see something like this:
wed, Dec 14, 2005
Note: Even though "=date" is a short script, it's actually made up of two parts. The "date" part tells the server, "Get me the date." The equal sign (=) tells the server to display the date in the Web page. If you typed just:
<% date %>
the server would get the current date from your system, but that's all. It wouldn't display it. There are times when it makes sense to use an ASP function without the equal sign.
Time
To display the current time by itself, type:
<% =time %>
where you want it to appear. When you view the page, you should see something like this:
10:10:09 AM
Now (Date and Time)
To display the current date and time, type:
<% =now %>
where you want them to appear. When you view the page, you should see something like this:
12/14/05 10:10:09 AM
Changing the Way Date and Time are Displayed
You can also use Active Server Pages (ASP) functions to customize the way the current date and time are displayed on your Web page. To do this, use the now function together with the following formatting functions.
Month and Monthname
To display the number of the current month in a Web page, type:
<% =month(now) %>
where you want it to appear. When you view the page in your browser, you'll see a 1 if the current month is January, 2 if it's February, and so on.
To display the name of the current month, type:
<% =monthname(month(now)) %>
where you want it to appear.
Day
To display the day of the current month, type:
<% =day(now) %>
where you want it to appear. When you view the page, you'll see a number between 1 and 31.
Year
To display the current year, type:
<% =year(now) %>
where you want it to appear.
u can find the full contents on asp black book. |