A
adiel
Hello, I am trying to access the properties and methods from a user
control within the code-behind file for a webform but I am receiving
the message:
Name 'MenuBar1' is not declared
It does not recognize the user control in the code behind...
Here is the code for the user control:
MenuBar.ascx:
<%@ Control Language="vb" AutoEventWireup="false"
Codebehind="MenuBar.ascx.vb" Inherits="TestApp.MenuBar"
TargetSchema="http://schemas.microsoft.com/intellisense/ie5" %>
....
MenuBar.ascx.vb:
Public MustInherit Class MenuBar
Inherits System.Web.UI.UserControl
Dim x As String
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
End Sub
Public Property testX() As String
Get
testX = x
End Get
Set(ByVal Value As String)
x = Value
End Set
End Property
End Class
This is the page that is using the code:
test.aspx:
<%@ Register TagPrefix="uc1" TagName="MenuBar" Src="MenuBar.ascx" %>
<%@ Page Language="vb" AutoEventWireup="false"
Codebehind="test.aspx.vb" Inherits="TestApp.test"%>
....
<uc1:menubar id="MenuBar1" runat="server"></uc1:menubar>
Then in my code behind:
test.aspx.vb
Dim y As String
y = MenuBar1.testX()
I receive the message:
Name 'MenuBar1' is not declared
....and MenuBar1 has the blue squiggly line....
I know the problem is that it does not understand what 'MenuBar1' is,
my question is, what am I missing so that i can get the code behind to
recognize 'MenuBar1'...
Thanks Before Hand,
Adiel
control within the code-behind file for a webform but I am receiving
the message:
Name 'MenuBar1' is not declared
It does not recognize the user control in the code behind...
Here is the code for the user control:
MenuBar.ascx:
<%@ Control Language="vb" AutoEventWireup="false"
Codebehind="MenuBar.ascx.vb" Inherits="TestApp.MenuBar"
TargetSchema="http://schemas.microsoft.com/intellisense/ie5" %>
....
MenuBar.ascx.vb:
Public MustInherit Class MenuBar
Inherits System.Web.UI.UserControl
Dim x As String
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
End Sub
Public Property testX() As String
Get
testX = x
End Get
Set(ByVal Value As String)
x = Value
End Set
End Property
End Class
This is the page that is using the code:
test.aspx:
<%@ Register TagPrefix="uc1" TagName="MenuBar" Src="MenuBar.ascx" %>
<%@ Page Language="vb" AutoEventWireup="false"
Codebehind="test.aspx.vb" Inherits="TestApp.test"%>
....
<uc1:menubar id="MenuBar1" runat="server"></uc1:menubar>
Then in my code behind:
test.aspx.vb
Dim y As String
y = MenuBar1.testX()
I receive the message:
Name 'MenuBar1' is not declared
....and MenuBar1 has the blue squiggly line....
I know the problem is that it does not understand what 'MenuBar1' is,
my question is, what am I missing so that i can get the code behind to
recognize 'MenuBar1'...
Thanks Before Hand,
Adiel