Wrox Programmer Forums
|
BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3
This is the forum to discuss the Wrox book Beginning ASP.NET 3.5: In C# and VB by Imar Spaanjaars; ISBN: 9780470187593
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 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 August 12th, 2013, 03:53 PM
Registered User
 
Join Date: Sep 2012
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Master.page error

I am getting an error after I have changed the code behind files for Master, default and login pages to use BasePage.
The compiler error message is
Make sure that the calls defined in this code file matches the 'inherits' attribute, and that it extends the correct base class.
The detail error is CS0030 - Cannot convert type 'ASP.masterpages_masterpage_master' to 'System.Web.UI.MasterPage'
I am also getting error code CS1061.

This is the master page code..
Code:
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
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;
using System.Xml.Linq;

public partial class MasterPage : BasePage
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
}
This is the base page code
Code:
using System;
using System.Web;

public class BasePage : System.Web.UI.Page
{
    private void Page_PreRender(object sender, EventArgs e)
    {
        if (this.Title == "Untitled Page")
        {
            throw new Exception("Page title cannot be \"Untitled Page\".");
        }
    }

    public BasePage()
    {
        this.PreRender += new EventHandler(Page_PreRender);
    }
}
Not sure what I did wrong as it looks the same as the sample code.

Thanks
Michael
 
Old August 13th, 2013, 03:28 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

You misread the instructions I think. You should only changes *pages* (that inherit from System.Web.UI.Page) and let them inherit the new BasePage. You should have left the code behind of the master page alone.

You can fix the problem by reverting the class definition in the code behind of the Master Page back to this:

Code:
public partial class MasterPage : System.Web.UI.MasterPage
Hope this helps,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
 
Old August 13th, 2013, 09:39 AM
Registered User
 
Join Date: Sep 2012
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you Imar





Similar Threads
Thread Thread Starter Forum Replies Last Post
calling a user control event from master page - --- error!!! nicklibee ASP.NET 3.5 Professionals 0 March 11th, 2012 01:06 AM
Setting the Master page hoses site... Page 92... richv BOOK: Beginning SharePoint 2010 Development 19 December 30th, 2010 10:21 AM
stuck in chap 4 with error (master page) moulot BOOK: ASP.NET 3.5 Enterprise Application Development with Visual Studio 2008: Problem Design Solutio 2 April 6th, 2010 06:07 AM
Master Page error michaelhruby BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 3 December 3rd, 2008 04:25 PM
VS2008 Master page error in <asp:contentPlaceHolde JesseTutterrow ASP.NET 2.0 Basics 1 December 10th, 2007 12:17 PM





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