spacer
Yehuda Shiran August 26, 2002
Client-Side vs Server-Side Scripting
Tips: August 2002

Yehuda Shiran, Ph.D.
Doc JavaScript

Developer News
OpenOffice 3.2 Lands Amid Critical Changes
Red Hat, IBM Firmly in KVM Virtualization Camp
Red Hat Talks Up Open Source Cloud Plans

In ASP.NET pages, JScript .NET functions and variables should be defined within <SCRIPT> blocks, while executable code must be enclosed within <% %> blocks. This is very different from the way you code JavaScript on the client side. Client-side JavaScript allows placing of executable code anywhere inside <SCRIPT> blocks.

The following ASP.NET page demonstrates the separation of function definitions and executable code. The function output() is defined in the <SCRIPT> block. The executable code that calls output() is placed inside the <% %> brackets:

  <%@ Page LANGUAGE="JScript" SRC="col116ex6.aspx.js" INHERITS="COL116.codeBehind" 
    AutoEventWireup="true" EnableViewState="true"%>
  <HTML>
  <SCRIPT LANGUAGE="JScript" runat="server">
  function output(str) {
    Response.Write(str);
  }
  var today : Date = new Date();
  </SCRIPT>
  <HEAD>
    <TITLE>Hello World Test</TITLE>
  </HEAD>
  <BODY STYLE="font-size:12; font-family:arial,verdana,sans-serif;">
    <P ALIGN="center">Today's date is  <% output(today); %></P>
    <FORM RUNAT="server">
    <P ALIGN="center"><ASP:LABEL ID="message" RUNAT="server"></ASP:LABEL></P>
    </FORM>
  </BODY>
  </HTML>
To learn more about JScript .NET and ASP.NET, go to Column 116, JScript .NET, Part X: Displaying Information.


People who read this tip also read these tips:

Look for similar tips by subject:


The Network for Technology Professionals

Search:

About Internet.com

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers

webref The latest from WebReference.com Browse >
Search Engine Optimization: Selecting and Embedding Keywords · Are Google's Language Translation Web Services Ready for Prime Time? · Installing and Using Meeplace, the Business Review CMS
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
IBM DB2 10 for z/OS: Justifying the Upgrade · Living La Vida Colo: Choosing the Right Colocation Facility · FTC Concerns over Social Media Privacy Linger