Peter,
Thanks for the clarification and advise.
Ok, so I pre-compiled the usercontrol into an assembly (bin/UControlVB.dll) and put the entry (<add assembly="UControlVB" />) in the web.config file, but I'm still having problems. At the usercontrol's declaration/reference in the page codebehind, I'm getting the error,
BC30389: 'UCTest.UControlClass' is not accessible in this context because it is 'Private'.
. I think my problem is how I've set up the @Control and @Register tags in the ascx and aspx files.
Could part of the problem be that I don't have option Explict and Strict tags in the ascx and aspx files, where i do have these set in the code behind code?
I've included the updated code below. If you could take another look and give me some pointers, I'd greatly appreciate it. Thank you for your time and attention on this.
Regards,
N. Demos
ERROR MESSAGE:
================================
Compiler Error Message: BC30389: 'UCTest.UControlClass' is not accessible in this context because it is 'Private'.
Source Error:
Line 12:
Line 13: Public lblNorm As Label
Line 14: Public uctrlLabel As UCTest.UControlClass
Line 15:
Line 16: Public Sub Page_Load(Source As Object, E As EventArgs)
Source File: C:\BegASPNET\UControlTest.aspx.
vb Line: 14
CODE:
================================
********************** UControl.ascx **********************
<%@ Control inherits="UControlClass" assembly="UControlVB" namespace="UCTest" debug="true" %>
<ASP:label id="lblULabel" text="UnInitiallized" runat="server" />
******************** UControl.ascx.
vb *********************
Option Explicit
Option Strict
Imports System
Imports System.Collections
Imports System.Web.UI
Imports System.Web.UI.WebControls
Namespace UCTest
Class UControlClass
Inherits System.Web.UI.UserControl
Protected lblULabel As Label
Protected m_strLabelText As String
Public Sub Page_Load(Source As Object, E As EventArgs)
If Not Page.IsPostBack Then
If m_strLabelText = "" Then m_strLabelText = "Initiallized"
End If
lblULabel.text = m_strLabelText
End Sub
Public Property LabelText As String
Get
Return m_strLabelText
End Get
Set
m_strLabelText = value
lblULabel.text = m_strLabelText
End Set
End Property
End Class
End Namespace
********************* UControlTest.aspx *********************
<%@ PAGE language="
VB" debug="true" src="UControlTest.aspx.
vb" inherits="UControlTestClass" %>
<%@ Register TagPrefix="UC" TagName="UCLabel" namespace="UCTest" inherits="UControlClass" assembly="UControlVB" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Final//EN" "http://www.w3.org/TR/html4/final.dtd">
<HTML>
<HEAD>
<TITLE></TITLE>
<STYLE type="text/css">
BODY {
color: #FFFFFF;
background-color: #000000;
}
</STYLE>
</HEAD>
<BODY>
<FORM id="frmForm" action="UControlTest.aspx" method="Post" runat="server">
<UC:UCLabel id="uctrlLabel" runat="server" />
<br />
<ASP:label id="lblNorm" text="Empty" runat="server" />
<INPUT type="submit" value="Submit" />
</FORM>
</BODY>
</HTML>
********************* UControlTest.aspx.
vb ********************
Option Explicit
Option Strict
Imports System
Imports System.Collections
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports UCTest
Class UControlTestClass
Inherits Page
Public lblNorm As Label
Public uctrlLabel As UCTest.UControlClass
Public Sub Page_Load(Source As Object, E As EventArgs)
If Not Page.IsPostBack Then
lblNorm.text = "First Value"
Else
lblNorm.text = uctrlLabel.LabelText
End If
End Sub
End Class