I have a custom user control that I made called OrderForm.ascx. I also have an .aspx file that utilizes the OrderForm control.
I want to access a control on the .aspx file from the OrderForm control. Is there a way to do this?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You could use the
FindControlmethod in the user control like this:As a note on the above, depending on where the Label is in the page, you may need to use recursion to find the Label.
You could also create a property on the page that returns the text of the Label:
To access the property from the user control, here are two options:
Option #1
Option #2