ASP.Net: Declaration Expected

Posted on December 1, 2005
Filed Under /dev/code/ | 388 views |

If you’re working in ASP.Net and writing some VB like so (nonsensical pseudo-code):

<script runat=”server” language=”VB”>
Label_Name = Left( theName, 5 )
</script>

and you get a Declaration Expected error that highlights a line inside your <script /> block you may not actually have an error with your code per se. You may just need to change how you declare the code block. Try this instead:

<%
Label_Name = Left( theName, 5 )
%>

Comments

One Response to “ASP.Net: Declaration Expected”

  1. Jason Nussbaum on December 4th, 2005 3:04 pm

    Actually, you should be able to do this instead:

    Dim Label_Name AS String = Left( theName, 5 )

    Or you could turn Option Explicit and Option Strict off, but I wouldn’t recommend that…

Leave a Reply