473,655 Members | 3,056 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Getting invalid token error but can't see why

I'm getting a compiler error on my ASP.NET page and I can't see the
cause. I have a simple C# class compiled into a DLL and placed in my
bin directory which has a public property QuestionText. When I try
and set the property the compiler throws up

Compiler Error Message: CS1519: Invalid token '=' in class, struct, or
interface member declaration

If I don't try and set the property it prints out the default value of
the property fine.

my code is below

<%@ Page Language="C#" %>
<%@ import Namespace="MyNa mespace" %>
<script runat="server">
PollQuestion pollQ = new PollQuestion();
pollQ.QuestionT ext = "My New Question";
</script>

<html>
<head>
</head>
<body>
<%=pollQ.Questi onText %>

</body>
</html>

The C# class is

[code:1:29c46e87 60]
using System;

namespace MyNamespace
{
public class PollQuestion
{
// private members
string strQuestionText ;

// empty constructor
public PollQuestion ()
{

}

// public accessors
public string QuestionText
{
get { return strQuestionText ;}
set { strQuestionText = value; }
}
}
}

[/code:1:29c46e87 60]

I've been trying to find the problem for a while now and so far
nobodys been able to help me.
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
Nov 18 '05 #1
3 2715
Property Type doesnot have parenthesis

Remove parenthesis from C# Class

"Twanger" <ia*@netbyte-dot-com.no-spam.invalid> wrote in message
news:40******** **@Usenet.com.. .
I'm getting a compiler error on my ASP.NET page and I can't see the
cause. I have a simple C# class compiled into a DLL and placed in my
bin directory which has a public property QuestionText. When I try
and set the property the compiler throws up

Compiler Error Message: CS1519: Invalid token '=' in class, struct, or
interface member declaration

If I don't try and set the property it prints out the default value of
the property fine.

my code is below

<%@ Page Language="C#" %>
<%@ import Namespace="MyNa mespace" %>
<script runat="server">
PollQuestion pollQ = new PollQuestion();
pollQ.QuestionT ext = "My New Question";
</script>

<html>
<head>
</head>
<body>
<%=pollQ.Questi onText %>

</body>
</html>

The C# class is

[code:1:29c46e87 60]
using System;

namespace MyNamespace
{
public class PollQuestion
{
// private members
string strQuestionText ;

// empty constructor
public PollQuestion ()
{

}

// public accessors
public string QuestionText
{
get { return strQuestionText ;}
set { strQuestionText = value; }
}
}
}

[/code:1:29c46e87 60]

I've been trying to find the problem for a while now and so far
nobodys been able to help me.
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com

Nov 18 '05 #2
Ignore the previous message

Replace <%=XXX%> with <%#XXX%>

"Twanger" <ia*@netbyte-dot-com.no-spam.invalid> wrote in message
news:40******** **@Usenet.com.. .
I'm getting a compiler error on my ASP.NET page and I can't see the
cause. I have a simple C# class compiled into a DLL and placed in my
bin directory which has a public property QuestionText. When I try
and set the property the compiler throws up

Compiler Error Message: CS1519: Invalid token '=' in class, struct, or
interface member declaration

If I don't try and set the property it prints out the default value of
the property fine.

my code is below

<%@ Page Language="C#" %>
<%@ import Namespace="MyNa mespace" %>
<script runat="server">
PollQuestion pollQ = new PollQuestion();
pollQ.QuestionT ext = "My New Question";
</script>

<html>
<head>
</head>
<body>
<%=pollQ.Questi onText %>

</body>
</html>

The C# class is

[code:1:29c46e87 60]
using System;

namespace MyNamespace
{
public class PollQuestion
{
// private members
string strQuestionText ;

// empty constructor
public PollQuestion ()
{

}

// public accessors
public string QuestionText
{
get { return strQuestionText ;}
set { strQuestionText = value; }
}
}
}

[/code:1:29c46e87 60]

I've been trying to find the problem for a while now and so far
nobodys been able to help me.
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com

Nov 18 '05 #3
Twanger wrote:
I'm getting a compiler error on my ASP.NET page and I can't see the
cause. I have a simple C# class compiled into a DLL and placed in my
bin directory which has a public property QuestionText. When I try
and set the property the compiler throws up

Compiler Error Message: CS1519: Invalid token '=' in class, struct, or
interface member declaration

If I don't try and set the property it prints out the default value of
the property fine.

my code is below

<%@ Page Language="C#" %>
<%@ import Namespace="MyNa mespace" %>
<script runat="server">
PollQuestion pollQ = new PollQuestion();
pollQ.QuestionT ext = "My New Question";
</script>

<html>
<head>
</head>
<body>
<%=pollQ.Questi onText %>

</body>
</html>


If you click the "Show Complete Compilation Source:" link on the error
page, you can see the C# source that the .aspx page is being parsed into
- this often helps with these kinds of problems.

In your case, the problem is that your script block gets parsed into the
..aspx page's class in the declarations block. So the first line (being
a declaration) is fine, but the next line is not.

Change you script block to something like:

<script runat="server">
PollQuestion pollQ = new PollQuestion();

public void Page_Load() {
pollQ.QuestionT ext = "My New Question";
}
</script>

so that the second line is inside the Page_Load() method.
--
mikeb
Nov 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
6857
by: evan.cooch | last post by:
Greetings. Suppose I have some function called "CheckIt" - some function to validate form data before submitting it to e CGI script. Pretend the name of the form is "TheForm". If I use the following code, everything work perfctly: <Input type=button VALUE="Submit your form" onClick="javascript:return CheckIt(TheForm)">
0
1347
by: s.caron | last post by:
Hi, I'm trying to open an aspx page but I have this error Compiler Error Message: CS1519: Invalid token '=' in class, struct, or interface member declaration in the line : usuario.Credentials = System.Net.CredentialCache.DefaultCredentials; If I put this code in a method like Page_load
0
5692
by: Ben Holness | last post by:
Hi all, I have a system which allows users to enter a message on a (PHP) website. This message is then put into a (MySQL) Database. A perl script then picks up the message and creates an XML document. The webpages, database and XML are all UTF-8, however every now and then I get an error in the XML parser that tells me I have an invalid token. This occurs when the message contains particular characters, although I don't
3
16227
by: Manuel | last post by:
I'm trying to compile glut 3.7.6 (dowbloaded from official site)using devc++. So I've imported the glut32.dsp into devc++, included manually some headers, and start to compile. It return a very strange error. In your experience, where I should looking to find the real error? Surely the sintax of glut is correct... gcc.exe -c glut_bitmap.c -o glut_bitmap.o -I"C:/Dev-Cpp/include" -I"../../include" -D__GNUWIN32__ -W -DWIN32 -DNDEBUG...
9
2158
by: Sebouh | last post by:
I'm very close of shooting myself in the head right now. Why in hell does free(xx) give me an error: *** glibc detected *** free(): invalid pointer: 0x08ce6158 *** // The function returns something like the argv parameter in main. char** parser (char* ch) { char** xx = NULL; char* temp; // contains the input which will be modified when using strtok int length = strlen (ch); // length of the string char* token;
1
16278
by: miamikk | last post by:
I have created XML files using BCP in SQL with FOR XML AUTO, ELEMENTS option. When I try to databind for XML file to a GridView in ASP.NET, I get an error " 'd/Commodity Description' has an invalid token". All I did was drag a GridView and selected the datasource as XML file. The XPath expression was selected automatically as "d/Commodity Description". I am not sure if this is an XML question or ASP.NET. I would appreciate if any XML...
3
4672
by: brad | last post by:
This works: This does not (one the end, 09 is used instead of 9) File "<stdin>", line 1 area_group = {001:06, 002:04, 003:04, 006:09} SyntaxError: invalid token Why does 09 cause an invalid token while 9 does not?
0
2490
by: Rod | last post by:
This is my first WCF service and it is running on my development machine (XP Pro SP2) under IIS, I am using wsHttpBinding. (I will eventually put it onto a Windows 2003 Server running under IIS on the server as an Intranet application). The strange is I've stepped through the code in the WCF service, it makes the call to the SQL Server database, it retrieves the data and puts it into the DataTable object, and then I close the connection and...
0
621
by: =?Utf-8?B?UmF2aQ==?= | last post by:
Hi, I have WCF service and integrated with STS (WS-Federation). The Service exposes 5 endpoints Win, UNT and Federated Windows, Federated UNT and Mex endpoint. My STS Service exposes 3 endpoints WIN, UNT and Mex. I am getting error when I sent a request from a client to WCF Service Fed-Win/ Fed-Unt endpoints. But it is passing for the regular Win and Unt endpoints.
0
8380
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8296
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8816
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8710
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8598
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6162
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5627
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4150
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4299
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.