Access a Method in a Master Page with Code-Behind
Page 3 of 3
Written by
Gregory Scot Collins
Friday, 16 June 2006, 7:09 AM
Create the Child.master file
Copy the contents of Listing 5 into a text editor, and then save the file as Child.master. Be sure to save it in the same folder as the Parent.master file.
Create the Child.master.cs file
Copy the contents of Listing 6 into a text editor, and then save the file as Child.master.cs. Be sure to save it in the same folder as the Parent.master file.
Create the Default.aspx file
Copy the contents of Listing 7 into a text editor, and then save the file as Default.aspx. Be sure to save it in the same folder as the Parent.master file.
Create the Default.aspx.cs file
Copy the contents of Listing 8 into a text editor, and then save the file as Default.aspx.cs. Be sure to save it in the same folder as the Parent.master file.
Try it
Copy or upload all six files to the same folder on your Web server, and then navigate to the Default.aspx page. In this example, we navigate to http://localhost/Default.aspx and receive the following response:
Load Page
* Processing ChildMasterFromPage()
* Processing ParentMasterFromPage()
Load Child.Master
* Processing ParentMasterFromChildMaster()
Load Parent.Master
Copyright ©2006
Braintrove. All rights reserved. This material may not be copied, published, broadcast, rewritten
or redistributed. You may, however, use the techniques, along with any associated code and files in
your development. This material is provided "AS IS" without warranty of any kind. You accept full
responsibility and liability for any and all results associated with use of this material.


Stumble It!
Digg It!
del.icio.us




