Response.Write not working

R

Rich

Hello,

in my ASP.NET c# project I can ouput text using
response.write from the code behind class. It works in the
aspx file using <asp:TextBox> controls too. It also works
using <%="Hello"%>. But using

response.write("hello");

I get the error
Compiler Error Message: CS1519: Invalid token '(' in
class, struct, or interface member declaration

Any Ideas why? Here is the complete code:
<%@ Page language="c#" Codebehind="WebForm1.aspx.cs"
AutoEventWireup="false" Inherits="CRS_Web.WebForm1" %>
<%@ Import Namespace="System.Data.SqlClient"%>
<%@ Import Namespace="CRS_Application"%>
<%@ Import Namespace="CRS_Web"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0
Transitional//EN" >
<HTML>
<HEAD>
<title>WebForm1</title>
<meta name="GENERATOR" Content="Microsoft
Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript"
content="JavaScript">
<meta name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body bgcolor="white" >
<script runat="server" language="c#">
Response.Write("Hello, Richard!" );
</script>
</body>
</HTML>
 
M

Marina

Any code in a server side script declared via <script> tag, has to contain
functions only.

If you just need to run some lines, they need to be in <% %> blocks.

Better yet, avoid server side scripts alltogether. This is almost always
possible.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,900
Latest member
Nell636132

Latest Threads

Top