spacer

Webref WebRef   Sitemap · Experts · Tools · Services · Newsletters · About i.com

home / experts / javascript / column116


JScript .NET, Part X: Displaying Information

Sr Instructional Designer D2L-Moodle,Clearance
WSI Nationwide, Inc.
US-NJ-Fort Monmouth

Justtechjobs.com Post A Job | Post A Resume
Developer News
News Flash: Adobe Has iPhone Workaround
Adobe's Flash 10.1 Goes Mobile (Minus iPhone)
A Salute to Visionary CEOs


Using <%= %>

The first method to display information from an ASP.NET page is with the <%= %> construct. In between the brackets you can put a JScript .NET variable name. The following ASP.NET line displays the value of the JScript .NET name variable:

<%= name %>

The following ASP.NET code demonstrates the display of a JScript .NET variable:


<%@ Page LANGUAGE="JScript" SRC="col116ex5.aspx.js"
  INHERITS="COL116.codeBehind"
  AutoEventWireup="true" EnableViewState="true"%>
<HTML>
<SCRIPT LANGUAGE="JScript" runat="server">
var name : String = "This line is set by JScript";
</SCRIPT>
<HEAD>
  <TITLE>Hello World Test</TITLE>
</HEAD>
<BODY STYLE="font-size:12; font-family:arial,verdana,sans-serif;">
  <P ALIGN="center">Hello, <%= name %></P>
  <FORM RUNAT="server">
  <P ALIGN="center"><ASP:LABEL ID="message" RUNAT="server">
  </ASP:LABEL></P>
  </FORM>
</BODY>
</HTML>

Notice how the variable name is inserted in between the brackets <%= and %>. Here is the Code Behind (see Column 115), col116ex5.aspx.js:

import System.Diagnostics;
import System.Xml.Serialization;
import System;
import System.Web.Services.Protocols;
import System.ComponentModel;
import System.Drawing;
import System.Web.Services;
import System.Web.UI.WebControls;


package COL116 {

  class codeBehind extends System.Web.UI.Page {

	public var message : System.Web.UI.WebControls.Label;

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

    }

  }

}

Notice that the package name is COL116. In the ASP.NET page, we inherit the class COL116.codeBehind. This Code Behind JScript .NET code displays the message "Hello World, Code Behind" by setting the Text property of the ASP:Label message. See Column 115 for more details.

We called the above ASP.NET page col116ex5.aspx. We put it in the directory d:\aspDemo, which is the virtual directory column113 of our IIS Web server. If you follow those same steps, you can display the ASP.NET page in your browser by setting the URL to http://localhost/column113/col116ex5.aspx. You should get the following page:


Next: How to use Response.Write()

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 >
Building a Banking Application Home Page with OOP · Mixing Scripting Languages · Review: phpFox, a Social Networking CMS with all the Bells and Whistles
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Enterprise 2.0: Social Networking in the Cloud · BroadSoft Marketplace Hastens Pace of Telephony Innovation · Review: HTC Hero for Sprint


Produced by Yehuda Shiran and Tomer Shiran
All Rights Reserved. Legal Notices.
Created: August 12, 2002
Revised: August 12, 2002

URL: http://www.webreference.com/js/column116/5.html