M
Mat
Hi,
I am having a bit of a problem trying to access / set properties of a
usercontrol from the parent codebehind.
This is what I have so far..
simple.aspx
<%@ Page Inherits="CodeBehindSimple" src="simple.vb" %>
<%@ Register TagPrefix="CC" TagName="Simple" Src="ucSimple.ascx"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"
"http://www.w3.org/TR/REC-html40/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
<title></title>
</head>
<body>
<form runat="server">
<CC:Simple id="mySimple" myParam="Hello from aspx" runat="server" />
</form>
</body>
</html>
simple.vb
Imports System
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.HtmlControls
Public Class CodeBehindSimple
Inherits Page
Protected WithEvents mySimple As Simple
sub Page_Load
mySimple.myParam = "Hello from codebehind"
end sub
End Class
ucSimple.ascx
<%@ Control Language="VB" Inherits="mySimpleNS.Simple"
src="./ucSimple.vb"%>
<asp:Label id="lbl_Simple" runat="server" />[/code]
ucSimple.vb
Imports System
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.HtmlControls
Namespace mySimpleNS
Public Class Simple
Inherits UserControl
Protected WithEvents lbl_Simple as Label
public property myParam as string
get
return lbl_Simple.text
end get
set
lbl_Simple.text = value
end set
end property
End Class
End Namespace
What should happen is that the parent codebehind (simple.vb) should
update the usercontrol CC:Simple "myParam" with "Hello from
codebehind". This dont happen, I get an error:
BC30002: Type 'Simple' is not defined.
If I comment out (in simple.vb)
'Protected WithEvents mySimple As Simple
'sub Page_Load
' mySimple.myParam = "Hello from codebehind"
'end sub
I get the text set in the parent (simple.aspx) output.
Anyone got any ideas? BTW I am not using VS.Net.
Cheers.
I am having a bit of a problem trying to access / set properties of a
usercontrol from the parent codebehind.
This is what I have so far..
simple.aspx
<%@ Page Inherits="CodeBehindSimple" src="simple.vb" %>
<%@ Register TagPrefix="CC" TagName="Simple" Src="ucSimple.ascx"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"
"http://www.w3.org/TR/REC-html40/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
<title></title>
</head>
<body>
<form runat="server">
<CC:Simple id="mySimple" myParam="Hello from aspx" runat="server" />
</form>
</body>
</html>
simple.vb
Imports System
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.HtmlControls
Public Class CodeBehindSimple
Inherits Page
Protected WithEvents mySimple As Simple
sub Page_Load
mySimple.myParam = "Hello from codebehind"
end sub
End Class
ucSimple.ascx
<%@ Control Language="VB" Inherits="mySimpleNS.Simple"
src="./ucSimple.vb"%>
<asp:Label id="lbl_Simple" runat="server" />[/code]
ucSimple.vb
Imports System
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.HtmlControls
Namespace mySimpleNS
Public Class Simple
Inherits UserControl
Protected WithEvents lbl_Simple as Label
public property myParam as string
get
return lbl_Simple.text
end get
set
lbl_Simple.text = value
end set
end property
End Class
End Namespace
What should happen is that the parent codebehind (simple.vb) should
update the usercontrol CC:Simple "myParam" with "Hello from
codebehind". This dont happen, I get an error:
BC30002: Type 'Simple' is not defined.
If I comment out (in simple.vb)
'Protected WithEvents mySimple As Simple
'sub Page_Load
' mySimple.myParam = "Hello from codebehind"
'end sub
I get the text set in the parent (simple.aspx) output.
Anyone got any ideas? BTW I am not using VS.Net.
Cheers.