Partager via


Basic Scripting (Compact 2013)

3/26/2014

The Windows Embedded Compact implementation of ASP uses the same syntax that IIS uses for the most basic ASP page operations.

Script commands are differentiated from text by the "<%" and "%>"delimiters. Using the specified scripting language processes these commands. Any command that is used within script delimiters must be valid for the scripting language.

ASP page delimiters may be included in any statement, expression, procedure, or operator that is valid for the scripting language. A statement is a syntactically complete unit that expresses one kind of action, declaration, or definition. The following code example shows a valid operation on Windows Embedded Compact–based ASP, sending the "Good Morning!" or "Hello!" greeting to the client browser, based on the time of day.

<% 
 Dim dtmHour, strGreeting
 dtmHour = Hour(Now())

 If dtmHour < 12 Then
  strGreeting = "Good Morning!"
 Else 
  strGreeting = "Hello!"
 End If  
 Response.Write(strGreeting)
%> 

Just as with IIS, it is possible to include HTML text between the sections of a statement. For example, the following script, which mixes HTML within an If...Then...Else statement, produces the same result as the script in the previous example.

<% 
 Dim dtmHour
 dtmHour = Hour(Now())
%>
<% If dtmHour < 12 Then %> 
 Good Morning!
<% Else %>
 Hello!
<% End If %>

The <%= %> directives inform ASP to print the value of the variable in the webpage.

For example, in the first script, the line in the following example sends the "Good Morning!" or "Hello!" string.

<%= strGreeting %>

If a requested file has an .asp extension but does not use any ASP functionality, it is sent to the client browser without undergoing any script processing. This practice is not recommended. There is more overhead that is associated with a file with an .asp extension than exists with other files. For optimal performance, files that do not contain ASP functionality should not have the .asp extension.

The ASP parser in Windows Embedded Compact does not return whitespace characters after an HTML element tag. To return a whitespace character, insert a space or line break after the element tag.

The following code example shows how to insert a line break after the element tag.

<%@ LANGUAGE = JSCRIPT %>
<HTML>
<BODY>
<% var x = 6; %>
<BR>X = <%= x%>
<BR>
This is another string
 
</BODY>
</HTML>

The following code example shows how to insert a non-breaking space after the element tag.

<%@ LANGUAGE = JSCRIPT %>
<HTML>
<BODY>
<% var x = 6; %>
<BR>X = <%= x%>
&nbsp
This is another string
 
</BODY>
</HTML>

See Also

Concepts

Active Server Pages Application Development
Web Server Implementation Details