T
tshad
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="TakeSurveyTest.aspx.vb" Inherits="TakeSurveyTest" %>
....
<div visible="true" runat="server">
<asplaceHolder ID="ContactInfo" runat="server"/> <br />
<--------------The error
<asp:Button ID="SubmitContact" Text="Submit Contact"
OnClick="SaveContact_Click" runat="server" /><br />
</div>
The ContactInfo control (ContactInfo.ascx):
<%@ Control Language="VB" AutoEventWireup="true"
CodeFile="ContactInfo.ascx.vb" Inherits="ContactInfo" %>
<td class="style4">
<asp:TextBox ID="objFirstName" Width="120px" runat="server" />
</td>
<td class="style2">
<asp:TextBox ID="objMiddleName" Width="120px" runat="server" />
</td>
And the ContactInfo.ascx.vb:
Imports System.Data
Imports System.Data.SqlClient
Imports MyFunctions.BitHandling
Imports System.Drawing
Imports MyFunctions
Imports RolesBasedAuthentication
Partial Class ContactInfo
Inherits System.Web.UI.UserControl
....
Public Property FirstName() As String
Get
Return objFirstName.Text
End Get
Set(ByVal value As String)
objFirstName.Text = Value
End Set
End Property
Public Property LastName() As String
Get
Return objLastName.Text
End Get
Set(ByVal value As String)
objLastName.Text = 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.Controls.Add(LoadControl("~/ContactInfo.ascx"))
But these lines give me the error:
parameters(1).Value = ContactInfo.FirstName
parameters(2).Value = ContactInfo.LastName
The error is:
'FirstName' is not a member of 'System.Web.UI.WebControls.PlaceHolder'
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="TakeSurveyTest.aspx.vb" Inherits="TakeSurveyTest" %>
....
<div visible="true" runat="server">
<asplaceHolder ID="ContactInfo" runat="server"/> <br />
<--------------The error
<asp:Button ID="SubmitContact" Text="Submit Contact"
OnClick="SaveContact_Click" runat="server" /><br />
</div>
The ContactInfo control (ContactInfo.ascx):
<%@ Control Language="VB" AutoEventWireup="true"
CodeFile="ContactInfo.ascx.vb" Inherits="ContactInfo" %>
<td class="style4">
<asp:TextBox ID="objFirstName" Width="120px" runat="server" />
</td>
<td class="style2">
<asp:TextBox ID="objMiddleName" Width="120px" runat="server" />
</td>
And the ContactInfo.ascx.vb:
Imports System.Data
Imports System.Data.SqlClient
Imports MyFunctions.BitHandling
Imports System.Drawing
Imports MyFunctions
Imports RolesBasedAuthentication
Partial Class ContactInfo
Inherits System.Web.UI.UserControl
....
Public Property FirstName() As String
Get
Return objFirstName.Text
End Get
Set(ByVal value As String)
objFirstName.Text = Value
End Set
End Property
Public Property LastName() As String
Get
Return objLastName.Text
End Get
Set(ByVal value As String)
objLastName.Text = 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.Controls.Add(LoadControl("~/ContactInfo.ascx"))
But these lines give me the error:
parameters(1).Value = ContactInfo.FirstName
parameters(2).Value = ContactInfo.LastName
The error is:
'FirstName' is not a member of 'System.Web.UI.WebControls.PlaceHolder'
Which is true, but how do access the ContactInfo parameters?
Thanks,
Tom