spacer
Yehuda Shiran August 25, 2002
Debugging JScript .NET within ASP.NET
Tips: August 2002

Yehuda Shiran, Ph.D.
Doc JavaScript

Developer News
Eclipse Helios Update Brings New PHP Tools
Internet Explorer 9 Ups Standards Support
JBoss Portal 5 Release Easier to Use

You can use the <%= %> construct to debug JScript .NET sections in your ASP.NET pages. The following example displays the variable name:

  <%@ 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>
The Code Behind JScript .NET code associated with the above ASP.NET page displays the message "Hello World, Code Behind" by setting the Text property of the ASP:Label message. See tip 020824.html for the exact code listing.

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:

As you can see, there are two messages on the page. The top one is displayed by the <%= %> construct for debugging messages. The bottom one is displayed by the Code Behind code, as part of the application.

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:

webref The latest from WebReference.com Browse >
Flashmaps' DynamicLocator: Interactive Maps for Small Areas · Flashmaps' AreaSelector: Interactive Maps for Wide Areas · The DB Mapper: Interactive Street-level Maps of U.S. and Canada
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
MS Access and MySQL · Cisco AutoQoS: VoIP QoS for Mere Mortals · While VoIP Adoption Explodes in Enterprise, Carrier Spending Lags