spacer
Yehuda Shiran August 24, 2002
Using the <%= %> Construct
Tips: August 2002

Yehuda Shiran, Ph.D.
Doc JavaScript

Developer News
Microsoft Shows Off Silverlight 4, IE9 Plans
Metasploit Expands Vulnerability Test Framework
HyperCard Reborn?

One of the methods 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";
      }
    }
  }
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:

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

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

webref The latest from WebReference.com Browse >
Rolling Out Your Own HTML Application Version Control · HTML 5: Client-side Storage · Working with Ajax Server Extensions
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Wi-Fi Product Watch, November 2009 · Chip Market Recovering From '08 Collapse · Low-Cost Tools to Kickstart Your New Business