ASP Best Practices

Previous Topic Next Topic

Delimiting Lines of Script

Lines of script should be blocked between a pair of delimiters, which are placed on a separate line, rather than written with delimiters on each line.

Instead of this:

  <% strEmail = Session("Email") %>
  <% strFirstName = Request.Form ("FirstName") %>
  <% strLastName = Request.Form ("LastName") %>

do this:

  <%
    strEmail = Session("Email")
    strFirstName = Request.Form ("FirstName")
    strLastName = Request.Form ("LastName")
  %>

For a single stand-alone line of script, keep the delimiters on the same line as the script.

Example:

  <% strEmail = Session("Email") %>

If the line of script is an ASP output directive (consisting of an equal sign and a variable), do not use a space between the equal sign and the delimiter.

Example:

  <%= strSubscrLName %>

If the line of script specifies an ASP language directive, do not leave a space between the @ and the delimiter. Do not leave spaces around the equal sign.

Example:

  <%@ LANGUAGE=VBScript %>

© 1997-1999 Microsoft Corporation. All rights reserved.