Active Server Pages Tutorial

Procedures and Functions

You can call procedures and functions from ASP code by enclosing the name of the procedure or function in the <% %> separators:

<% Function CalcHalf(somenumber) If isnumeric(somenumber) then CalcHalf = somenumber/2 Else CalcHalf=0 End if Response.Write(Calchalf) End Function %> Half-Price Discount! $<%CalcHalf(70)%>

Adding Comments

Including comments in your code helps to clarify the purpose of the code when you return to it later. To include a comment in an ASP page, begin it with

:

<% Response.Write(“Welcome to my first ASP page!”) %>

Showing Friendly Error Messages

When developing and previewing your ASP pages, it’s normal to encounter errors. To make bug-fixing easier, turn on the “Show friendly HTTP error messages” option in Internet Explorer:

  1. In Internet Explorer, open the Tools menu and selection Options.
  2. In the Internet Options dialog box, select the Advanced tab.
  3. Scroll to the Browsing section.
  4. Check the box that says Show friendly HTTP error messages.
  5. Click OK.

Now, when Internet Explorer returns an error page, you can scroll to the bottom of the page to view specific information on that error, including the line in the code where the error occurs.

Leave a Reply

Your email address will not be published. Required fields are marked *