As the script server converts the whole script file to script code on the first pass (all code outside <script runat="server"> tags becomes ‘write’ statements) it is possible to use conditional execution statements on either side of HTML code. Thus a page can look very different to the browser depending on a variable.

Example

<script language="javascript" runat="server">

  if (request.verify == "true") {

</script>

<h2>Your user id has been verified</h2>

Welcome to our web site. As your user id has been verified you will be able to search our catalog and buy on line. etc

etc

<script language=”javascript” runat="server">

  }

  else {

</script>

<h2>Sorry, that was not a valid user id </h2>

Welcome to our web site. As your user id has not been verified you will not be able to search our catalog and buy on

line. etc etc

<script language="javascript" runat="server">

 }

</script>

This example shows an ‘if’ statement being split over three server-side script sections with two different versions of the HTML text. The version displayed will depend on the ‘request.verify’ variable.

Comment on this topic

Topic ID: 150040