Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Accessing Objects properties in User Control

Reply
Thread Tools

Accessing Objects properties in User Control

 
 
tshad
Guest
Posts: n/a
 
      08-03-2006
I have a User Control with 4 Textboxes.

I want to be able to access the properties (.text, .visible, .enable etc)
directly from outside the Controls as the normal properties (.text, .visible
etc).

For example: at the moment I need to create a new property for each TextBox
since I can't figure out how to set up "text" as a property.

*********************************************
<Script Runat="Server">

Public Property Street As String
Get
Return txtStreet.Text
End Get
Set
txtStreet.Text = Value
End Set
End Property

Public Property City As String
Get
Return txtCity.Text
End Get
Set
txtCity.Text = Value
End Set
End Property

Public Property State As String
Get
Return txtState.Text
End Get
Set
txtState.Text = Value
End Set
End Property

Public Property ZIP As String
Get
Return txtZIP.Text
End Get
Set
txtZIP.Text = Value
End Set
End Property

</Script>

<p>Street Address:
<br>
<asp:TextBox
ID="txtStreet"
Runat="Server" />

<p>City:
<br>
<asp:TextBox
ID="txtCity"
Runat="Server" />

<p>State:
<br>
<asp:TextBox
ID="txtState"
Runat="Server" />

<p>ZIP:
<br>
<asp:TextBox
ID="txtZIP"
Runat="Server" />
*********************************************
In my .aspx file I may have the following:

<SuperCompany:Address
ID="ctlBillingAddress"
Runat="Server" />

I need to do:

ctlBillingAddress.Street = "xxx"

I understand that I can't do ctlBillingAddress.text as there would be no way
to know which textbox you are referring to.

I am curious if there is a better way to set this up with multiple objects
in my controls?

Thanks,

Tom


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Designer Support: How to have user control's properties appear in IDE's properties window? Max2006 ASP .Net 2 07-13-2007 01:45 PM
Accessing user control properties David ASP .Net 0 04-12-2007 07:54 AM
Accessing USER CONTROL which is inside Masterpagethrough Another USER Control inside normal page. Kiran More ASP .Net Web Controls 2 11-14-2006 12:58 PM
Accessing Datagrid properties within a user control from the outside Craig G ASP .Net 3 11-30-2004 02:51 PM
accessing the readonly properties of a listmenu with a user control? Moe Sizlak ASP .Net 4 07-17-2004 06:01 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57