I have the opportunity to see a problem posted on the Forum:
After the button is executed on the webpage, the user control that is dynamically loaded will be discarded when the sub-user control's button is executed. Therefore, we need to focus on the key points to be processed.
After the sub-user control in the same phase is dynamically loaded, its status also needs to be maintained. Otherwise, it will be discarded when it is passed to another sub-user control.
Another key point is the sub-user control, how to pass values to another user control.
After figuring out the key technical points, everything is easy.
On the website, create a webpage Default. aspx, two user controls UcA. ascx and UcB. ascx
In Default. aspx:
Go to UcA. aspx
Go to UcB. aspx
The html code of all web pages and user controls is complete.
UcB. aspx. cs needs to obtain a value. It is unclear where the value comes from, whether it is a webpage or another user control. Just like when I was a child, I asked my parents for money. We don't have to know whether the money was from their parents or borrowed from them. We just need to pay for it.
Insus. NET creates an interface that has a Set attribute.
The user control UcB. aspx. cs implements this interface:
Go to Default. aspx. cs to write the program:
ViewState is used to retain the Dynamically Loaded user control.
Go to UcA. ascx. cs:
The execution result of webpage running: