|
August 27, 2002 Using Response.Write() Tips: August 2002
Yehuda Shiran, Ph.D.
|
|
You can display text from an ASP.NET page by using the JScript .NET Response.Write() method. You can enclose Response.Write() within a <% %> block like this:
You can also include it in a function definition and call the function inside a <% %> block. In ASP.NET pages, 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 usage of
The JScript .NET code defines the variable today which is initialized to today's date and time. We also define the function output() which displays its argument with Response.Write(). Within the ASP.NET code, we call output() with the today variable as its argument:
Let's call this code col116ex6.aspx. The following window shows the outcome of setting the URL of your browser to http://localhost/column113/col116ex6.aspx:
People who read this tip also read these tips: Look for similar tips by subject: |