Wrox Programmer Forums
|
BOOK: Beginning ASP.NET 4.5.1 : in C# and VB
This is the forum to discuss the Wrox book Beginning ASP.NET 4.5.1: in C# and VB by Imar Spaanjaars; ISBN: 978-1-118-84677-3
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 4.5.1 : in C# and VB 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 May 7th, 2019, 04:24 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Take a look at this:

Code:
<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPages/Frontend.Master" AutoEventWireup="true" CodeBehind="Template.aspx.cs" Inherits="$relurlnamespace$_$safeitemname$" %>
Look at the CodeBehind reference: it still says Template, rather than this:

CodeFile="$safeitemname$.aspx.cs"

Also, it should be CodeFile rather than CodeBehind. Here's the first line of the template that comes with the book:

<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPages/Frontend.master" AutoEventWireup="true" CodeFile="$safeitemname$.aspx.cs" Inherits="$relurlnamespace$_$safeitemname$" %>

I recommend you either redo the template exercise, or copy the one from the book to your ItemTemplates folder on disk.
__________________
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 May 7th, 2019, 04:37 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Something else I realized: Is this web site project or a web application project? The CodeBehind suggests it's the latter, while the book uses the former. Does every web form you create have one code behind file or two? (An additional one with the word Designer in it)

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 May 7th, 2019, 05:35 PM
Registered User
 
Join Date: May 2018
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The instructions in the exercise on page 213 specifically say, "You must leave the CodeFile attribute alone; VS will change it to the right Code Behind file automatically whenever you add a new page to the site." That's why I didn't change it. My temporary file matched what was shown on page 213.

However, I am still getting the same errors. Here is the new page I created with the template:

<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPages/Frontend.Master" AutoEventWireup="true" CodeFile="May7TestPage.aspx.cs" Inherits="$relurlnamespace$_May7TestPage" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="cpMainContent" runat="server">
</asp:Content>

You can see that $relurlnamespace$ has not been substituted in the Inherits attribute.

Here is the template file (I called it FinalTemp):

<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPages/Frontend.Master" AutoEventWireup="true" CodeFile="$safeitemname$.aspx.cs" Inherits="$relurlnamespace$_$safeitemname$" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="cpMainContent" runat="server">
</asp:Content>

And here is FinalTemp.aspx.cs:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace dkwebapp1
{
public partial class $relurlnamespace$_$safeitemname$ : BasePage
{
protected void Page_Load(object sender, EventArgs e)
{

}
}
}

I am using Visual Studio Professional version 15.9.11. Is there a setting that used to be a default that maybe isn't any more? I copied your code directly into my file and it still isn't working...
 
Old May 7th, 2019, 05:54 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

I am on 16 and it works fine there. Can you answer the question about the type of project? Also, can you upload the project somewhere so I can take a look?
__________________
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!





Similar Threads
Thread Thread Starter Forum Replies Last Post
Chapter 6 BasePage Darkryder007 BOOK: Beginning ASP.NET 4.5 : in C# and VB 8 April 4th, 2015 04:04 AM
Chapter 6 BasePage & Template Try It Out PhilC BOOK: Beginning ASP.NET 4 : in C# and VB 7 April 4th, 2013 02:54 PM
Basepage Khalil BOOK: Beginning ASP.NET 4 : in C# and VB 3 December 7th, 2011 06:42 AM
BasePage Question Rushino BOOK: Beginning ASP.NET 4 : in C# and VB 9 April 9th, 2010 12:48 PM
Reference to BasePage member4953 BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 3 March 27th, 2009 01:45 PM





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