P
Phil Certain
Hi,
I'm trying to do something very simple...or at least it should be. I
have created a host page (gen.aspx) and a very simple user control
(us.ascx). The corresponding code-behind files are gen.aspx.vb and
uc.ascx.vb. With simple html or self contained vb in the user control,
everything is fine and dandy. So the next stage is to pass back a
simple variable from the user control to the host page. I used VS.NEt
to create the files.
The code-behind files are:
gen.aspx.vb:
Imports System
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports Microsoft.VisualBasic
Imports System.Web.UI.UserControl
Imports testing 'see below
Public Class gen
Inherits System.Web.UI.Page
Protected rightnav2 As New incRightNav2
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
End Class
uc.ascx.vb:
Imports System
Imports System.Web.UI.WebControls
Imports System.Configuration.ConfigurationSettings
Namespace testing
Public Class incRightNav2
Inherits System.Web.UI.UserControl
Public strMainCSS
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
End Sub
Public Sub switchCSS(ByVal sCSS As Object, ByVal e As
EventArgs)
If sCSS.text = "larger" Then
strMainCSS = AppSettings("altCSS")
btn_switchCSS.Text = "smaller"
Label1.Text = strMainCSS
Else
strMainCSS = AppSettings("mainCSS")
btn_switchCSS.Text = "larger"
Label1.Text = strMainCSS
End If
Label1.Text = strMainCSS
End Sub
End Class
End Namespace
incRightNav2 is the id of the user control when instantiated in
gen.aspx.
All I want to do at this point is pass the variable 'strMainCSS' back
to the calling page, but not even getting that far! I get one of two
errors when calling gen.aspx via the browser. With 'Namespace testing'
included in us.ascx.vb, I get:
Compiler Error Message: BC30466: Namespace or type 'testing' for the
Imports 'testing' cannot be found.
Source Error:
Line 15: Imports System.Web.UI.UserControl
Line 16:
Line 17: Imports testing
Line 18:
Line 19:
And if I remove the 'Namespace testing' wrapper, I always get:
Compiler Error Message: BC30002: Type 'incRightNav2' is not defined.
Source Error:
Line 62: Public rightnav2 As New incRightNav2
Line 63:
Line 64:
In each case, VS.Net 'intellisense' finds the class incRightNav2 and no
design time errors are thrown.
So it seems that it's falling over due to some 'type' issue. Its
logical that gen.aspx.vb needs to know about uc.ascx.vb, but I just
can't find a way to get the host page code-behind to reference the user
control code-behind.
I hope its something really basic that I'm doing wrong here...any help
really appreciated.
Phil
I'm trying to do something very simple...or at least it should be. I
have created a host page (gen.aspx) and a very simple user control
(us.ascx). The corresponding code-behind files are gen.aspx.vb and
uc.ascx.vb. With simple html or self contained vb in the user control,
everything is fine and dandy. So the next stage is to pass back a
simple variable from the user control to the host page. I used VS.NEt
to create the files.
The code-behind files are:
gen.aspx.vb:
Imports System
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports Microsoft.VisualBasic
Imports System.Web.UI.UserControl
Imports testing 'see below
Public Class gen
Inherits System.Web.UI.Page
Protected rightnav2 As New incRightNav2
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
End Class
uc.ascx.vb:
Imports System
Imports System.Web.UI.WebControls
Imports System.Configuration.ConfigurationSettings
Namespace testing
Public Class incRightNav2
Inherits System.Web.UI.UserControl
Public strMainCSS
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
End Sub
Public Sub switchCSS(ByVal sCSS As Object, ByVal e As
EventArgs)
If sCSS.text = "larger" Then
strMainCSS = AppSettings("altCSS")
btn_switchCSS.Text = "smaller"
Label1.Text = strMainCSS
Else
strMainCSS = AppSettings("mainCSS")
btn_switchCSS.Text = "larger"
Label1.Text = strMainCSS
End If
Label1.Text = strMainCSS
End Sub
End Class
End Namespace
incRightNav2 is the id of the user control when instantiated in
gen.aspx.
All I want to do at this point is pass the variable 'strMainCSS' back
to the calling page, but not even getting that far! I get one of two
errors when calling gen.aspx via the browser. With 'Namespace testing'
included in us.ascx.vb, I get:
Compiler Error Message: BC30466: Namespace or type 'testing' for the
Imports 'testing' cannot be found.
Source Error:
Line 15: Imports System.Web.UI.UserControl
Line 16:
Line 17: Imports testing
Line 18:
Line 19:
And if I remove the 'Namespace testing' wrapper, I always get:
Compiler Error Message: BC30002: Type 'incRightNav2' is not defined.
Source Error:
Line 62: Public rightnav2 As New incRightNav2
Line 63:
Line 64:
In each case, VS.Net 'intellisense' finds the class incRightNav2 and no
design time errors are thrown.
So it seems that it's falling over due to some 'type' issue. Its
logical that gen.aspx.vb needs to know about uc.ascx.vb, but I just
can't find a way to get the host page code-behind to reference the user
control code-behind.
I hope its something really basic that I'm doing wrong here...any help
really appreciated.
Phil