Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Child Control Properties

Status
Not open for further replies.

VBAHole22

Programmer
Nov 7, 2002
41
US
How can I set the Text property of a child textbox control in a panel control on an asp.net web form?

I have panel1 and it has textBox5 in it. I want to set the text in textbox5 to "Hello". How do you do this?

I know how you can't do it and this is what I have been trying:

Dim ctl As System.Web.UI.WebControl
Dim child As TextBox
ctl = FindControl("panel1")
child = CType(ctl.Controls(1), TextBox)
child.Text = "Hey"

This always gives an inavlid cast for child. I tried webControl.TextBox with the same results.

Any suggestions?
 
Code:
Dim ctl As System.Web.UI.WebControl
Dim child As TextBox
ctl = FindControl("panel1")
child = CType(ctl.Controls.FindControl("textBox5"), TextBox) 
child.Text = "Hey"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top