asp.netvb.netwebforms

VB .net asp label undefined


I want to set asp label to catch Cookie content,

I set

<p><asp:Label ID="lblUserID" runat="server" Text=""></asp:Label></p>

in USERINFO.aspx

then set

Public Class USERINFO
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not IsPostBack Then
            If (Request.Cookies("userInfo")("vID") IsNot Nothing) Then
                lblUserID.Text = Request.Cookies("userInfo")("vID").ToString
            End If
        End If
    End Sub

End Class

in USERINFO.aspx.vb

But got visual studio alert :lblUserID not defined

What should I do to connect the label correctly ?


Solution

  • Thanks to @Andrew Morton, I solve the problem. My issue is caused by that I didn't declare lblUserID in in USERINFO.aspx.designer.vb, I also didn't wrote the Inherits tag in USERINFO.aspx like

    <%@ Page Language="vb" AutoEventWireup="false" CodeBehind="USERINFO.aspx.vb" **Inherits="MyProject.USERINFO"** %>
    

    Correctly.