Introduction to ASP. NET user control

  • 2020-06-15 08:00:54
  • OfStack

Access data in user controls on the page:

Method 1:
Using the FindControl method of the user control, find the control in the user control and step 1 to get its data (ID, which does not need to be processed in the control, but needs to know the control to be used in the user control)
Method 2:

Add a property (method) to the control to access data in the user control (simple, but not flexible enough when used in the target page)

A control in a user control that accesses a page control:

Method 1:
Use the Parent property in the user control to find the page, and the FindControl method to find the control to access

Method 2:
Add events to user controls, process events on the page, and then implement controls that access the page in the control


Related articles: