Solved label not declared

Posted on 2007-07-27
Last Modified: 2012-08-14
Hi, im fairly new to and i need some help fixing my code for test.aspx (all on one page, no codebehind), heres the page:

<%@ Page Language="vb" %>
<%@ import Namespace="System" %>
<%@ Import Namespace="System.Data" %>

<script Language="VB" Debug="true" RunAt="Server">
Private Sub Page_load (byval sender as system.object, byval e as system.eventargs) handles mybase.load
      'Protected WithEvents lblresult As Label.
        dim strchoice as string
      strchoice = "one"
      lblresult.text = strchoice
End sub

Private sub mysub(byref strtemp as string)
      strtemp= "two"
End sub

<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>New Page 1</title>
<meta name="GENERATOR" content="Microsoft FrontPage 6.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<form runat="server">
<asp:Label id="lblResult">

when i run it i get this error:
Compiler Error Message: BC30451: Name 'lblresult' is not declared.
ive tried:
"dim lblresult as label" and "Protected WithEvents lblresult As Label."
I dont know what is wrong, but i know it should be fairly easy to fix. Do i need to make a class for this thing work, cause i dont think i should (its 1.1)? Dont worry about the byval and byref, that was what i was planning to test before i got that error. Help please, thanks
Question by:Nizix
    LVL 7

    Assisted Solution

    <asp:Label id="lblResult" runat="server">
    LVL 2

    Accepted Solution

    <asp:Label id="lblResult" runat="server">  (You were missing runat attribute)

    You don't have to declare it. You can directly access it with the label Id i.e. lblResult.

    In case you use Code Behind :
    For Visual Studio 2003
    you have to declare the variable in the code behind file.

    For Visual Studio 2005
    controls are declared in the code behind designer file.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Top 6 Sources for Identifying Threat Actor TTPs

    Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

    In my previous article ( we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
    A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
    how to add IIS SMTP to handle application/Scanner relays into office 365.
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

    794 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now