The button event on the master page gets the content of the Child page, and the button event gets
This example shows how to obtain the content of some subpages by using the button event on the master page.
In the master, there is an button event. When you browse some subpages, you can click the button on the master page to obtain the content of the current page.
There are many subpages, but we do not get the content of each subpage, and the content of each subpage is different. Therefore, you need to let the parent page events know which child pages need to be obtained.
To put it bluntly, this is what we call interfaces. Let different objects process the same behavior.
Let's take a look at this interface:
Using System; using System. collections. generic; using System. linq; using System. web; // <summary> /// Summary description for IGetSubPageContentable /// </summary> namespace Insus. NET {public interface IGetSubPageContentable {string GetResult () ;}} Source Code
Next, all the subpages for Interface Behavior execution must implement the above interface:
Default. aspx. cs:
Default1.aspx. cs:
Default2.aspx. cs:
Default3.aspx. cs:
The subpage of the demo is like this to implement the interface.
Next, for the button event on the master page, I need to know which subpages have implemented interfaces:
OK. Key procedures and implementation processes are shared in the blog. All. aspx and. master can be used freely!
Real-time Demonstration: