473,660 Members | 2,468 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

User Control not showing properties

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

Oct 5 '08 #1
1 1891
I can statically do this by registering the control:

<%@ Register TagPrefix="uc" TagName="Contac tInfo" Src="contactInf o.ascx" %>

and then change the Placeholder line to:

<uc:ContactIn fo ID="ContactInfo " runat="server" />

Then the information errors go away because not the "ContactInf o" points to
UserControl (ControlInfo.as cx).

But if I use loadControl and Add to the control, I can't seem to use the
properties.

There must be a way to do this?

Thanks,

Tom

"tshad" <tf*@dslextreme .comwrote in message
news:eE******** ******@TK2MSFTN GP06.phx.gbl...
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

Oct 5 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
3585
by: Jim | last post by:
I am having some trouble with user controls and would appreciate any input / advice on where to go with this... :) 1. The first problem, and perhaps the root of the others, is that I have several user controls that are inherited user controls, based on one class, which is in turn based on System.Windows.Forms.UserControl. We'll call this class "UserControlBase". My first problem is that UserControlBase implements some public...
0
1904
by: Jim | last post by:
I am having some trouble with user controls and would appreciate any input / advice on where to go with this... :) 1. The first problem, and perhaps the root of the others, is that I have several user controls that are inherited user controls, based on one class, which is in turn based on System.Windows.Forms.UserControl. We'll call this class "UserControlBase". My first problem is that UserControlBase implements some public...
1
840
by: Amber | last post by:
The DataGrid allows you to make columns visible or invisible on demand - even edit and other special columns. This article will show you how it is done. Some developers have reported problems controlling the visibility of columns in the DataGrid control. The problem usually comes down to one fact. The DataGrid has a property called AutoGenerateColumns. The default value is "True". This means that when AutoGenerateColumns is set to True,...
1
2370
by: Chris | last post by:
novice question here... I am building a registration form while learning Asp.Net. I am having trouble passing data between "dynamically"-added server controls. To simplify, I have a single Registration.aspx page that contains 2 panels. Each panel is loaded with a user control during Page_Load(): protected Panel panel1; protected Panel panel2;
2
3725
by: mharness | last post by:
Hello, I've tried a number of examples showing how to read the properties of a user control from an aspx file where the code is on the html view of the form but I can't figure out how to read them from the aspx.vb. Can anyone tell me how to declare the user control in the aspx.vb file so that I can read the properties? I did add "Protected WithEvents UC1 As System.Web.UI.UserControl" to the component code behind form but that's the...
6
4065
by: evandelagrammaticas | last post by:
Hi all. I have spent the better part of a day scouring the newsgroups and I am sure that I must have come across the solution a number of times - but I am still a real newbie at asp.net so please forgive me beforehand if I ask anything really simple or ridiculous. I am going to simplify my query... the structure of my example is ---> page1.aspx ------> page1.aspx.vb --->control1.ascx for the sake of simplicity this is what I am trying...
9
5241
by: Brian Hampson | last post by:
I am trying to determine all the groups which the current user has permissions to add a member. Here's my code: foreach (System.DirectoryServices.SearchResult ADSearchres in ADSearch.FindAll()) { //ActiveDs.ADSearchres.Properties
6
2767
by: ajk | last post by:
Hi I was wondering how to show different properties in design and run-mode for a user control? Is it possible to do this when implementing the System.ComponentModel.ICustomTypeDescriptor interface? e.g. when selecting the control from a toolbox with controls other properties show up when the program is in design mode than in run mode.
0
1006
by: DigitalDan3 | last post by:
Visual Studio 2008 C#. Web Controls I have a simple user control (TextBoxViewer) that contains 2 controls a TextBox and a Label Control. The usercontrol exposes a default "Text" property and also has a Mode Enum for Edit and Display. Depending on the mode if "Edit" then TextBox is visible and Label is hidden and the opposite is true for Display. I know I can expose a public readonly property of the TextBox that is contained inside my user...
0
8428
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8341
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8851
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8630
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7360
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4176
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4342
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1982
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1739
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.