• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 600
  • Last Modified:

Accessing user controls at page level using asp.net 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,

1 Solution
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.

Featured Post

Configuration Guide and Best Practices

Read the guide to learn how to orchestrate Data ONTAP, create application-consistent backups and enable fast recovery from NetApp storage snapshots. Version 9.5 also contains performance and scalability enhancements to meet the needs of the largest enterprise environments.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now