HELP - Not recognizing VB Sub's

M

Marc Violette

<Reply-To: (e-mail address removed)>

Hello,

I'm hoping someone can help me out here... I'm a beginner ASP.NET
developper, and am trying to follow a series of exercises in the book
entitled "Microsoft ASP.NET Step By Step" by Microsoft Press.

When I try to display *any* ASP.NET page with a Sub() somewhere, I get the
following error:

------ BEGIN ERROR MESSAGE -------------
Line: 5
Char: 9
Error: Expected ';'
Code:0
URL: http://localhost/Exercises/HelloContainer.aspx
------ END ERROR MESSAGE -----------------

I thought this might have something to do with the fact that the compiler
thinks I want to use a different language than VB. So I set the "Page
Language" directive to "VB", as indicated in the code below.

Here is the code for "HelloContainer.aspx". Note that the line# and char#
in the error message corresponds to the space after the "Sub" decleration.

------ BEGIN HelloContainer.aspx ------------------
<%@ Page Language="vb" %>
<%@ Register TagPrefix="ASPNETSBS" TagName="Hello" Src="Hello.ascx" %>

<script runat="server">
Sub Page_Load(Sender As Object, E As EventArgs)
MyHello.Name = "Andrew"
MYHello.SayHello
End Sub

</script>
<html>
<head>
</head>
<body>
<ASPNETSBS:Hello id="MyHello" runat="server"
OnLoad="MyHello_Load"></ASPNETSBS:Hello>
</body>
</html>
-------------------------------------------------------------

I am getting very frustrated... No matter what is after the "Sub" it won't
continue past that point. I tried creating a GLOBAL.ASAX file, and a
WEB.CONFIG file, but to no avail...

Any help would be appreciated.

Please send replies to: (e-mail address removed)

Thanks a million!
 
M

Mark Fitzpatrick

The error might not be what you think. This looks like a browser error, not
a server error. If it's a browser error than there is a good chance it has
absolutely nothing to do with the sub. Use a View Source in IE to view the
actual code that the browser is throwing the error from. Chances are it's
some JavaScript that is throwing the error that is being emitted by the
control or one of the controls as JavaScript will usually get emitted at the
very top of the file.

Hope this helps,
Mark Fitzpatrick
Microsoft MVP - FrontPage
 
M

Marc Violette

Hi,

Thanks for the tip, but no go... No matter what I type in between the
"<script>" the compiler doesn't seem to understand it. I am running .NET FW
1.1 and basic code appears to work (like the simple "Response.Write")
function, but nothing else...

Any other ideas ?

Thanks again.
 
K

Karl

My initial guess is that something's wrong in your Hello.ascx page and/or
codebehind.

Karl
 
M

Marc Violette

Hi, thanks for your help...

It appears it is *all* of my user controls... No matter what control I use
(either ones I develop or the sample ones from the CD), I always get the
same error message saying I am missing a ";" before the first Sub of any
embedded <script> sections.

Does anyone know of a section in a configuration file that would have
anything to do with this ?

Maybe I'll try a C# script instead of a VB script... This would help
determine if it is a problem with the compiler not recognizing the Sub, or
if it's a more complex issue surrounding my installation.

Thanks.
 
K

Karl

This is true even if the user control is blank? What if it doens't have a
codebehind section?

In your web.config, what's the defaultLanguage of the compilation element
set to?

karl
 

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,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top