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)%>
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:
- In Internet Explorer, open the Tools menu and selection Options.
- In the Internet Options dialog box, select the Advanced tab.
- Scroll to the Browsing section.
- Check the box that says Show friendly HTTP error messages.
- 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.