Importing Namespace

R

RN1

The following code resides in a user-control (UCProperties.ascx)

-------------------------------------------
<%@ Control Language="VB" Inherits="UCPropertiesNS.UCProperties"
Src="UCProperties.ascx.vb" %>
<asp:TextBox ID="txt" runat="server"/><br>
<asp:Button ID="btn" runat="server"/>
-------------------------------------------

This is the corresponding code-behind of the above user-control
(UCProperties.ascx.vb):

-------------------------------------------
Imports System
Imports System.Data

Namespace UCPropertiesNS
Public Class UCProperties : Inherits UserControl
Public txt As TextBox
Public WithEvents btn As Button

Public WriteOnly Property MakeVisible() As Boolean
Set(ByVal value As Boolean)
txt.Visible = value
End Set
End Property

Public Property ButtonText() As String
Get
ButtonText = btn.Text
End Get
Set(ByVal value As String)
btn.Text = value
End Set
End Property

Public Event ButtonClick(ByVal obj As Object, ByVal ea As
EventArgs)
Protected Sub ButtonClicked(ByVal obj As Object, ByVal ea As
EventArgs) Handles btn.Click
RaiseEvent ButtonClick(obj, ea)
End Sub
End Class
End Namespace
-------------------------------------------

This is the ASPX page that uses the above user-control
(UCProperties.aspx):

-------------------------------------------
<%@ Page Language="VB" Explicit="True" Inherits="UCProps"
Src="UCProperties.aspx.vb" %>
<%@ Register TagName="TBox" TagPrefix="TB" Src="UCProperties.ascx" %>

<form runat="server">
<TB:TBox ID="tb" OnButtonClick="ShowHide" ButtonText="HIDE TEXTBOX"
MakeVisible="true" runat="server"/>
</form>
-------------------------------------------

This is the code-behind of the above ASPX page (UCProperties.aspx.vb)

-------------------------------------------
Imports System
Imports System.Data
Imports UCPropertiesNS

Public Class UCProps : Inherits Page
Public tb As UCProperties
Sub ShowHide(ByVal obj As Object, ByVal ea As EventArgs)
If (tb.ButtonText = "HIDE TEXTBOX") Then
tb.MakeVisible = False
tb.ButtonText = "SHOW TEXTBOX"
ElseIf (tb.ButtonText = "SHOW TEXTBOX") Then
tb.MakeVisible = True
tb.ButtonText = "HIDE TEXTBOX"
End If
End Sub
End Class
-------------------------------------------

Now when I run the ASPX page, the following error gets generated:

--------------------
Type 'UCProperties' is not defined.
--------------------

pointing to the line

--------------------
Public tb As UCProperties
--------------------

in UCProperties.aspx.vb. What am I doing wrong here?

Thanks,

Ron
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,763
Messages
2,569,563
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top