spacer
Yehuda Shiran August 13, 2002
Writing Pages without Code Behind
Tips: August 2002

Yehuda Shiran, Ph.D.
Doc JavaScript

Developer News
Google Going Native With Chrome
Mozilla Fixes Firefox Flaws as 3.5 Release Nears
Microsoft and Novell Still Bosom Buddies

Sometimes, using Code Behind is too complicated for a simple task. You can put your JScript .NET code in the ASP.NET page directly. Here is the Hello World application in one piece, for your reference:

  <%@ Page LANGUAGE="JScript" %>
  <HTML>
  <HEAD>
    <TITLE>Hello World Test</TITLE>
  <SCRIPT LANGUAGE="JScript" RUNAT="server">

  public function Page_Load(sender:Object, E:System.EventArgs) : void {
    message.Text = "Hello World, Code Behind";
  }

  </SCRIPT>
  </HEAD>
  <BODY STYLE="font-size:12; font-family:arial,verdana,sans-serif;">
    <FORM RUNAT="server">
      <P ALIGN="center"><ASP:LABEL ID="message" RUNAT="server"></ASP:LABEL></P>
    </FORM>
  </BODY>
  </HTML>
As you can see, the principles are the same. The Page_Load() function is invoked automatically when the page loads. It sets the Text property of the message ID to "Hello World, Code Behind". This ASP.NET file is self-sufficient, and you don't need to import any classes.

To learn more about JScript .NET and ASP.NET, go to Column 115, JScript .NET, Part IX: Code Behind.


People who read this tip also read these tips:

Look for similar tips by subject:

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Reprints, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs

webref The latest from WebReference.com Browse >
XML and PHP Simplified · Creating a ASP.NET Contact Form · Data Filtering with PHP
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Intel to Host Live Nehalem Q&A · 12 Tips to Troubleshoot Network File-Sharing · 10 Tips for Selling on Kijiji