View Single Post
  #1 (permalink)  
Old October 25th, 2006, 12:08 AM
Asp.Net Asp.Net is offline
Authorized User
Points: 176, Level: 3
Points: 176, Level: 3 Points: 176, Level: 3 Points: 176, Level: 3
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Sep 2006
Location: , , .
Posts: 41
Thanks: 0
Thanked 0 Times in 0 Posts
Default Listing 8-10 and Listing 8-16.

A MusterPage that exposes a custom property.
Listing 8-10. Page_266 Chapter_8 Professional ASP.NET 2.0

Hello There!
I discovered a little problem in the code.
By having the brackets you will receive a following {error}:
'ASP.masterpage_masterpage_master.PageHeadingTitle ' is a 'property' but is used like a 'method'
Fix: Remove the brackets.

Take a look at the <html> code of the MasterPage:
//----------------------------------------------------------

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>My Company MasterPage</title>
</head>
<body>
    <form id="form1" runat="server">
     <table cellpadding ="3" border ="1">
        <tr bgcolor ="silver">
         <td colspan ="2">
         <h1><% = PageHeadingTitle() %></h1>
         <b>User's GUID:&nbsp;&nbsp;
         <asp:Label ID ="Label1" runat ="server"></asp:Label></b>
         </td>
        </tr>
            <tr>
             <td>
             <asp:ContentPlaceHolder ID ="ContentPlaceHolder1" runat ="server">
             </asp:ContentPlaceHolder>
             </td>
                 <td>
                     <asp:ContentPlaceHolder ID ="ContentPlaceHolder2" runat ="server">
                     </asp:ContentPlaceHolder>
                 </td>
                 </tr>
                    <tr>
                        <td colspan ="2">
                            Copyright 2006 - My Company
                        </td>
                    </tr>
            </table>
        </form>
</body>
</html>

//-----------------------------------------------------------------


Using Page_Preinit to assign the master page programmaticallly
This is Listing 8-16. Page 272.

Concerns toVB and C#

This one is tricky :)

//------------------------------------------------------
<%@ Page Language="C#" %>


<script runat="server">
                    // Do not write PreInit Use small (i)
    protected void Page_Preinit(object sender, System.EventArgs e)
    {
        Page.MasterPageFile = "~/masterPage/MasterPage2.master";
    }

</script>

//----------------------------------------------------------
Bye :)