ASP eating Javascript from VB code

L

Lloyd Sheen

I have a page with the following script (no code behind ,using WebMatrix -
customer doesn't want to spend money on dev tools).

'Dim psInfo() As String
'psInfo = Split(psSV, "/")
psURL += "UID=" & psInfo(0).Trim & "&Lang=" & psInfo(1).Trim

popupScript = "<script language='javascript'>"
popupScript += "window.open('PopUp.aspx', 'CustomPopUp', "
popupScript += "'width=200, height=200, menubar=yes, resizable=no')"
'popupScript += "</script>"

Response.Redirect(psURL)
End Sub

When I run this I get the following error:

Compilation Error
Description: An error occurred during the compilation of a resource required
to service this request. Please review the following specific error details
and modify your source code appropriately.

Compiler Error Message: BC30289: Statement cannot appear within a method
body. End of method assumed.

Source Error:


Line 280: #End ExternalSource
Line 281:
Line 282: Public Sub New()
Line 283: MyBase.New
Line 284: Dim dependencies As System.Collections.ArrayList


If I remove the line 'popupScript += </script> and notice it is
commented the error goes away. I guess ASP parsing is not that good.

Any suggestions.

Lloyd Sheen
 
M

mikeb

Lloyd said:
I have a page with the following script (no code behind ,using WebMatrix -
customer doesn't want to spend money on dev tools).

'Dim psInfo() As String
'psInfo = Split(psSV, "/")
psURL += "UID=" & psInfo(0).Trim & "&Lang=" & psInfo(1).Trim

popupScript = "<script language='javascript'>"
popupScript += "window.open('PopUp.aspx', 'CustomPopUp', "
popupScript += "'width=200, height=200, menubar=yes, resizable=no')"
'popupScript += "</script>"

Response.Redirect(psURL)
End Sub

When I run this I get the following error:

Compilation Error
Description: An error occurred during the compilation of a resource required
to service this request. Please review the following specific error details
and modify your source code appropriately.

Compiler Error Message: BC30289: Statement cannot appear within a method
body. End of method assumed.

Source Error:


Line 280: #End ExternalSource
Line 281:
Line 282: Public Sub New()
Line 283: MyBase.New
Line 284: Dim dependencies As System.Collections.ArrayList


If I remove the line 'popupScript += </script> and notice it is
commented the error goes away. I guess ASP parsing is not that good.

If you notice the server-side script in your ASPX page is delimited with
<script> ... </script> tags. The parser sees the </script> tag in your
string literal and believes the server-side code block is done.

Note that the ASPX parser is language independent, so it knows nothing
of VB.NET (or C#) comments.

The fix is to not have that sequence of character tokens in the
server-side block. Change the line to:

'popupScript += "<" + "/script>"

or something.
 
L

Lloyd Sheen

Thanks, pretty much what I came up with.

MS --- There are literals in VB. Those literal can contain things you
might be looking for. Fix your parser.

Lloyd Sheen
 
Y

Yama

Hello there,

Try to change it:
popupScript += "</" & "script>"

Hope it resolves your issue.
Please let me know,

Yama
 
L

Lloyd Sheen

All fixes by not having the tag show work. I would just like MS to fix the
problem. I have to say that the new development platforms and .NET have
many problems. Not being able to parse HTML though is a problem that I
would think MS would fix. Surely they understand when it reaches a literal
value. I guess not. Maybe all those MS haters are correct.

Perhaps too much work on security and not enough on getting the dev tools
correct. I can only imagine from reading the newsgroups over that last
couple of years that there is an inordinate amount of workaround code in
current .NET apps. I wonder what will happen with next release to break all
those workarounds.

Lloyd Sheen
 
K

Kevin Spencer

Listen, Lloyd. Web Matrix is FREE, and NOT SUPPORTED. So, what are you
complaining about? Why don't you go out and buy the professional software
that Microsoft sells (Visual Studio.Net)? There is a reason why so many
people are willing to pay for it - it saves them money in the long run.
Think about it. For VS.Net you pay once, and get a whole lot of productivity
increase. Which costs more - software or programmer salaries?

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
 
P

Paul Whitehurst

Kevin said:
Listen, Lloyd. Web Matrix is FREE, and NOT SUPPORTED. So, what are you
complaining about? Why don't you go out and buy the professional software
that Microsoft sells (Visual Studio.Net)? There is a reason why so many
people are willing to pay for it - it saves them money in the long run.
Think about it. For VS.Net you pay once, and get a whole lot of productivity
increase. Which costs more - software or programmer salaries?


Kevin,

Llyod's problem has nothing to do with using Web Matrix. His problem
exists soley because he is NOT using code behind. The fact the the
parser only looks for the literal string '</script>' anywhere after
<script> is a design flaw. Forcing developers to create a work around
eg. "<" & "/script>" is not very friendly.

Cheers,

Paul
 

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

Top