D
David Webb
I am having trouble setting the property to a Web User Control from the
Parent page.
Here's the Web User Control: WebUserControl1.ascx
HTML:-----------------------------------------------------------
<%@ Control Language="vb" AutoEventWireup="false"
Codebehind="WebUserControl1.ascx.vb" Inherits="TEST.WebUserControl1"
TargetSchema="http://schemas.microsoft.com/intellisense/ie5" %>
<DIV align="center">
<asp:Label id="Label1" runat="server">Label</asp:Label></DIV>
-----------------------------------------------------------
CodeBehind:-----------------------------------------------------------
Imports System
Imports System.Web.UI
Imports System.Web.UI.HtmlControls
Public Class WebUserControl1
Inherits System.Web.UI.UserControl
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()
End Sub
'NOTE: The following placeholder declaration is required by the Web Form
Designer.
'Do not delete or move it.
Private designerPlaceholderDeclaration As System.Object
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub
#End Region
Protected WithEvents Label1 As System.Web.UI.WebControls.Label
Public Property LabelText() As String
Get
Return Label1.Text
End Get
Set(ByVal Value As String)
Label1.Text = Value
End Set
End Property
End Class
-----------------------------------------------------------
Here's the Parent form: ParentForm.aspx
HTML:-----------------------------------------------------------
<%@ Page Language="vb" AutoEventWireup="false"
Codebehind="ParentForm.aspx.vb" Inherits="TEST.ParentForm" %>
<%@ Register TagPrefix="uc1" TagName="WebUserControl1"
Src="WebUserControl1.ascx" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>ParentForm</title>
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body>
<form id="Form1" method="post" runat="server">
<P align="center">
<uc1:WebUserControl1 id="WebUserControl11"
runat="server"></uc1:WebUserControl1></P>
</form>
</body>
</HTML>
-----------------------------------------------------------
CodeBehind:-----------------------------------------------------------
Imports System
Imports System.Web.UI
Imports System.Web.UI.HtmlControls
Public Class ParentForm
Inherits System.Web.UI.Page
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()
End Sub
'NOTE: The following placeholder declaration is required by the Web Form
Designer.
'Do not delete or move it.
Private designerPlaceholderDeclaration As System.Object
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub
#End Region
Protected WithEvents WUC1 As WebUserControl1
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
WUC1.LabelText = "TEST 1234"
End Sub
End Class
Parent page.
Here's the Web User Control: WebUserControl1.ascx
HTML:-----------------------------------------------------------
<%@ Control Language="vb" AutoEventWireup="false"
Codebehind="WebUserControl1.ascx.vb" Inherits="TEST.WebUserControl1"
TargetSchema="http://schemas.microsoft.com/intellisense/ie5" %>
<DIV align="center">
<asp:Label id="Label1" runat="server">Label</asp:Label></DIV>
-----------------------------------------------------------
CodeBehind:-----------------------------------------------------------
Imports System
Imports System.Web.UI
Imports System.Web.UI.HtmlControls
Public Class WebUserControl1
Inherits System.Web.UI.UserControl
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()
End Sub
'NOTE: The following placeholder declaration is required by the Web Form
Designer.
'Do not delete or move it.
Private designerPlaceholderDeclaration As System.Object
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub
#End Region
Protected WithEvents Label1 As System.Web.UI.WebControls.Label
Public Property LabelText() As String
Get
Return Label1.Text
End Get
Set(ByVal Value As String)
Label1.Text = Value
End Set
End Property
End Class
-----------------------------------------------------------
Here's the Parent form: ParentForm.aspx
HTML:-----------------------------------------------------------
<%@ Page Language="vb" AutoEventWireup="false"
Codebehind="ParentForm.aspx.vb" Inherits="TEST.ParentForm" %>
<%@ Register TagPrefix="uc1" TagName="WebUserControl1"
Src="WebUserControl1.ascx" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>ParentForm</title>
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body>
<form id="Form1" method="post" runat="server">
<P align="center">
<uc1:WebUserControl1 id="WebUserControl11"
runat="server"></uc1:WebUserControl1></P>
</form>
</body>
</HTML>
-----------------------------------------------------------
CodeBehind:-----------------------------------------------------------
Imports System
Imports System.Web.UI
Imports System.Web.UI.HtmlControls
Public Class ParentForm
Inherits System.Web.UI.Page
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()
End Sub
'NOTE: The following placeholder declaration is required by the Web Form
Designer.
'Do not delete or move it.
Private designerPlaceholderDeclaration As System.Object
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub
#End Region
Protected WithEvents WUC1 As WebUserControl1
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
WUC1.LabelText = "TEST 1234"
End Sub
End Class