Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
BOOK: Professional ASP.NET 2.0 and Special Edition; ISBN: 978-0-7645-7610-2; ISBN: 978-0-470-04178-9
This is the forum to discuss the Wrox book Professional ASP.NET 2.0 Special Edition by Bill Evjen, Scott Hanselman, Devin Rader, Farhan Muhammad, Srinivasa Sivakumar; ISBN: 9780470041789
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional ASP.NET 2.0 and Special Edition; ISBN: 978-0-7645-7610-2; ISBN: 978-0-470-04178-9 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 25th, 2006, 12:08 AM
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 :)
 
Old February 6th, 2008, 01:11 PM
Registered User
 
Join Date: Oct 2007
Location: Indian Head, MD, USA.
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Listing 8-10 and 8-11 purport to show how a public property set on the master page using inline server-side code is accesible from the content page. However when I implement this code in my masterpage and content page like so;

 Dim m_sPageHeadingTitle As String = "HIFLD Web Site"
        Public Property PageHeadingTitle() As String
            Get
                Return m_sPageHeadingTitle
            End Get
            Set(ByVal value As String)
                m_sPageHeadingTitle = value
            End Set
        End Property

an on the content page;

<%@ Page Language="VB" MasterPageFile="~/HIFLDMaster.master" Title="HSIP Gold Request Form" %>
<%@ MasterType VirtualPath="~/HIFLDMaster.master" %>

<script runat="server" language="vb">
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)

        Me.Master.PageHeadingTitle = "HSIP Gold Request Form"
    End Sub

</script>


I get an error on the content page stating 'PageHeadingTitle' is not a member of 'System.Web.UI.MasterPage'. Were there changes made to ASP.Net 2.0 Master pages after the book was written that keeps this code from working?




Similar Threads
Thread Thread Starter Forum Replies Last Post
Listing 16-8 smiller BOOK: Professional ASP.NET 2.0 and Special Edition; ISBN: 978-0-7645-7610-2; ISBN: 978-0-470-04178-9 5 October 24th, 2006 08:39 AM
Listing members quiksilverhg Excel VBA 1 October 6th, 2005 05:09 AM
Ch. 10 Directory listing superkooi BOOK: Beginning ASP 3.0 1 March 3rd, 2005 07:39 AM
Listing records Adam H-W Classic ASP Basics 4 November 17th, 2003 12:15 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.