ASP. NET 2.0 is a major improvement over the previous version, that is, it provides a master page. So how does it communicate with the content page? You can refer to the following example to implement its function (the code is very simple, and the source code download is not commented out ):
Using system;
Using system. Data;
Using system. configuration;
Using system. collections;
Using system. Web;
Using system. Web. Security;
Using system. Web. UI;
Using system. Web. UI. webcontrols;
Using system. Web. UI. webcontrols. webparts;
Using system. Web. UI. htmlcontrols;
// Master page
Public partial class masterpage: system. Web. UI. masterpage
...{
Protected void page_load (Object sender, eventargs E)
...{
}
Protected void btnmaster_click (Object sender, eventargs E)
...{
Label LBL = This. contentplaceholder1.findcontrol ("lblcontent") as label;
Response. Write ("<script language = 'javascript '> alert ('" + LBL. Text + "'); </SCRIPT> ");
}
}
The content page is as follows:
Using system;
Using system. Data;
Using system. configuration;
Using system. collections;
Using system. Web;
Using system. Web. Security;
Using system. Web. UI;
Using system. Web. UI. webcontrols;
Using system. Web. UI. webcontrols. webparts;
Using system. Web. UI. htmlcontrols;
// Content Page
Public partial class default2: system. Web. UI. Page
...{
Protected void page_load (Object sender, eventargs E)
...{
}
Protected void btncontent_click (Object sender, eventargs E)
...{
Label LBL = This. master. findcontrol ("lblmaster") as label;
Response. Write ("<script language = 'javascript '> alert ('" + LBL. Text + "'); </SCRIPT> ");
}
}