In VB 2008, I have a user control added to the page in the PageLoad event -
but the properties are causing me an error.
The program (TakeSurveyTest .aspx) using the control (ContactInfo):
<%@ Page Language="VB" AutoEventWireup ="true" Trace="true"
CodeFile="TakeS urveyTest.aspx. vb" Inherits="TakeS urveyTest" %>
....
<div visible="true" runat="server">
<asp:PlaceHolde r ID="ContactInfo " runat="server"/<br />
<--------------The error
<asp:Button ID="SubmitConta ct" Text="Submit Contact"
OnClick="SaveCo ntact_Click" runat="server" /><br />
</div>
The ContactInfo control (ContactInfo.as cx):
<%@ Control Language="VB" AutoEventWireup ="true"
CodeFile="Conta ctInfo.ascx.vb" Inherits="Conta ctInfo" %>
<td class="style4">
<asp:TextBox ID="objFirstNam e" Width="120px" runat="server" />
</td>
<td class="style2">
<asp:TextBox ID="objMiddleNa me" Width="120px" runat="server" />
</td>
And the ContactInfo.asc x.vb:
Imports System.Data
Imports System.Data.Sql Client
Imports MyFunctions.Bit Handling
Imports System.Drawing
Imports MyFunctions
Imports RolesBasedAuthe ntication
Partial Class ContactInfo
Inherits System.Web.UI.U serControl
....
Public Property FirstName() As String
Get
Return objFirstName.Te xt
End Get
Set(ByVal value As String)
objFirstName.Te xt = Value
End Set
End Property
Public Property LastName() As String
Get
Return objLastName.Tex t
End Get
Set(ByVal value As String)
objLastName.Tex t = Value
End Set
End Property
So the properties are being defined but in the TakeSurveyTest. aspx.vb file
is saying ContactInfo doesn't have these properties. I load the conrol in
my PageLoad as:
ContactInfo.Con trols.Add(LoadC ontrol("~/ContactInfo.asc x"))
But these lines give me the error:
parameters(1).V alue = ContactInfo.Fir stName
parameters(2).V alue = ContactInfo.Las tName
The error is:
'FirstName' is not a member of 'System.Web.UI. WebControls.Pla ceHolder'
Which is true, but how do access the ContactInfo parameters?
Thanks,
Tom
but the properties are causing me an error.
The program (TakeSurveyTest .aspx) using the control (ContactInfo):
<%@ Page Language="VB" AutoEventWireup ="true" Trace="true"
CodeFile="TakeS urveyTest.aspx. vb" Inherits="TakeS urveyTest" %>
....
<div visible="true" runat="server">
<asp:PlaceHolde r ID="ContactInfo " runat="server"/<br />
<--------------The error
<asp:Button ID="SubmitConta ct" Text="Submit Contact"
OnClick="SaveCo ntact_Click" runat="server" /><br />
</div>
The ContactInfo control (ContactInfo.as cx):
<%@ Control Language="VB" AutoEventWireup ="true"
CodeFile="Conta ctInfo.ascx.vb" Inherits="Conta ctInfo" %>
<td class="style4">
<asp:TextBox ID="objFirstNam e" Width="120px" runat="server" />
</td>
<td class="style2">
<asp:TextBox ID="objMiddleNa me" Width="120px" runat="server" />
</td>
And the ContactInfo.asc x.vb:
Imports System.Data
Imports System.Data.Sql Client
Imports MyFunctions.Bit Handling
Imports System.Drawing
Imports MyFunctions
Imports RolesBasedAuthe ntication
Partial Class ContactInfo
Inherits System.Web.UI.U serControl
....
Public Property FirstName() As String
Get
Return objFirstName.Te xt
End Get
Set(ByVal value As String)
objFirstName.Te xt = Value
End Set
End Property
Public Property LastName() As String
Get
Return objLastName.Tex t
End Get
Set(ByVal value As String)
objLastName.Tex t = Value
End Set
End Property
So the properties are being defined but in the TakeSurveyTest. aspx.vb file
is saying ContactInfo doesn't have these properties. I load the conrol in
my PageLoad as:
ContactInfo.Con trols.Add(LoadC ontrol("~/ContactInfo.asc x"))
But these lines give me the error:
parameters(1).V alue = ContactInfo.Fir stName
parameters(2).V alue = ContactInfo.Las tName
The error is:
'FirstName' is not a member of 'System.Web.UI. WebControls.Pla ceHolder'
Which is true, but how do access the ContactInfo parameters?
Thanks,
Tom
Comment