Accessing user controls at page level using web forms

Hi All,

Is there a better way to access user control (ascx) elements, as in the controls within an ascx control from the aspx page level instead of using myUserControl.findControl().

Is there a way that user controls could be inherited into an aspx page or apply a namespace to my page to make all elements of the user control automatically accessible via the page?

Your help and syntax would be much appreciated.

Many thanks,

Who is Participating?
Obadiah ChristopherConnect With a Mentor Commented:
Automatically visible on the page is not possible.

You could do something like this in the usercontrol

<asp:TextBox ID="txt1" runat="server" Width="100px"></asp:TextBox>

Open in new window

public TextBox txt1TextBox
           return txt1;

Open in new window

// In aspx page you can access the control using this property

Open in new window

rito1Author Commented:
Excellent, thank you very much.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.