Response.Write not working

  • Thread starter Thread starter Rich
  • Start date Start date
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>
 
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.
 
Back
Top