access user control' s control

J

js

hi,
I have a user control, but I don't have source code, only have the aspx
file, I added one text (txtMyName) to it, how to access this textbox and get
the value form user input? Please advice, many thanks.
 
T

Teemu Keiski

Hi,

you can run FindControl against the user control (using ID of the UC) on the
aspx page

Dim txtMyName As TextBox =
DirectCast(MyUserControl1.FindControl("txtMyName"), TextBox)

where "MyUserControl1" is ID of the user control on aspx page
 
J

js

Thanks Teemu ...


Teemu Keiski said:
Hi,

you can run FindControl against the user control (using ID of the UC) on
the aspx page

Dim txtMyName As TextBox =
DirectCast(MyUserControl1.FindControl("txtMyName"), TextBox)

where "MyUserControl1" is ID of the user control on aspx page

--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
http://blogs.aspadvice.com/joteke
 
J

js

Thanks for the help,
Can I assign a value to it?

Teemu Keiski said:
Hi,

you can run FindControl against the user control (using ID of the UC) on
the aspx page

Dim txtMyName As TextBox =
DirectCast(MyUserControl1.FindControl("txtMyName"), TextBox)

where "MyUserControl1" is ID of the user control on aspx page

--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
http://blogs.aspadvice.com/joteke
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top