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:A ddress
ID="ctlBillingA ddress"
Runat="Server" />
I need to do:
ctlBillingAddre ss.Street = "xxx"
I understand that I can't do ctlBillingAddre ss.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