problem with two </script> tags

  • Thread starter Thread starter bob
  • Start date Start date
B

bob

Hi,

This code gives two errors, one on each </script> tag:
the first: "statement cannot appear in method body"
the last: "end of tag has no matching start tag"

Any way to solve this?
Thanks
Bob

<script runat="server">
Protected Sub DetailsView1_ItemInserted(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.DetailsViewInsertedEventArgs)
Dim jv As String
jv = "<script type='text/javascript' language='javascript'>" _
& " alert('Thanks, data are in');" _
& "</script>"
Response.Write(jv)
End Sub
</script>
 
bob said:
This code gives two errors, one on each </script> tag:
the first: "statement cannot appear in method body"
the last: "end of tag has no matching start tag"
<script runat="server">
Protected Sub DetailsView1_ItemInserted(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.DetailsViewInsertedEventArgs)
Dim jv As String
jv = "<script type='text/javascript' language='javascript'>" _
& " alert('Thanks, data are in');" _
& "</script>"
Response.Write(jv)
End Sub
</script>

Sounds like an IDE bug. You could do something like:

& " alert('Thanks, data are in');" _
& "</sc" & "ript>"

Which may trick the IDE into thinking it isn't a closing tag.
 
bob said:
Hi, thanks for replying.
I get now the java-error: ; expected

Looks like the Javascript is wrong, try this:

jv = "<script type='text/javascript' language='javascript'>" &
Environment.NewLine & _
" alert('Thanks, data are in')" & Environment.NewLine & _
"</scr" & "ipt>"
 
Thanks, but still javascript error (expected ;)


Leon Mayne said:
Looks like the Javascript is wrong, try this:

jv = "<script type='text/javascript' language='javascript'>" &
Environment.NewLine & _
" alert('Thanks, data are in')" & Environment.NewLine & _
"</scr" & "ipt>"
 
bob said:
Thanks, but still javascript error (expected ;)

Works OK for me. Do you have any other scripts on the page? Could you do a
'View source' in IE when you get the error and post the complete <script>
section that's causing the problem?
 
Back
Top