 |
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
|
|
|
|
|

December 19th, 2008, 12:42 AM
|
|
Friend of Wrox
|
|
Join Date: Dec 2008
Posts: 119
Thanks: 26
Thanked 0 Times in 0 Posts
|
|
p 213
Hi Imar:
I'm not sure I'm doing this right. After exporting the "MyBasePage" as instructed, I do see it now in the template region under My Templates.
But when I add a new page by right clicking on my website name and choosing Add new item, and adding a new page called TestPage.aspx, the page's title is TestPage. But it doesn't inherit from BasePage.
In the page's source view it inherits from TestPage:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="TestPage.aspx.cs" Inherits="TestPage" %>
And in the Code Behind file it inherits from System.Web.UI.Page:
public partial class TestPage : System.Web.UI.Page
Is that what the test page file is supposed to state?
Was I suppose to click on the MyBasePage when I added the page and named it TestPage?
Rachel
Last edited by Rachel; December 19th, 2008 at 12:59 AM..
|
|

December 19th, 2008, 02:48 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Sounds like you forgot to change the classname in the code behind file.... Or maybe you didn't save that file before you exported the template and only saved the .aspx?
You should have Inherits BasePage in the Code Behind as well...
Imar
|
|

December 19th, 2008, 10:01 PM
|
|
Friend of Wrox
|
|
Join Date: Dec 2008
Posts: 119
Thanks: 26
Thanked 0 Times in 0 Posts
|
|
I'm re-doing it.
On page 210 in the try it out, I wasn't sure the first time I did this and am still not sure now as I do it again, what you mean there by making sure it... "is based on the master page in the MasterPages folder".
What I am doing is :
I right click my website c:\BegASPNET\WebSite1\, then "Add new item", then choose "Web Form", name it Template.aspx, and make sure both the check boxes are checked for code behind and "Select Master Page"?
Is that correct?
Rae
|
|

December 19th, 2008, 10:28 PM
|
|
Friend of Wrox
|
|
Join Date: Dec 2008
Posts: 119
Thanks: 26
Thanked 0 Times in 0 Posts
|
|
After re-doing, I end up with the same file info in the test page added after exporting the MyBasePage file:
From Testpage's aspx file:
<%@ Page Language="C#" MasterPageFile="~/MasterPages/MasterPage.master" AutoEventWireup="true" CodeFile="TestPage.aspx.cs" Inherits="TestPage" Title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="cpMainContent" Runat="Server">
my optional comments .
</asp:Content>
----------------------------------
from code behind (aspx.cs) file:
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.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
public partial class TestPage : BasePage
{
protected void Page_Load(object sender, EventArgs e)
{
}
}
---------
I made sure I "saved all". I clicked the Save All button at top of my menu couple of times to be sure and saved the page individually as well before exporting it.
Rachel
|
|

December 19th, 2008, 10:30 PM
|
|
Friend of Wrox
|
|
Join Date: Dec 2008
Posts: 119
Thanks: 26
Thanked 0 Times in 0 Posts
|
|
Quote:
Originally Posted by Imar
Sounds like you forgot to change the classname in the code behind file.... Or maybe you didn't save that file before you exported the template and only saved the .aspx?
You should have Inherits BasePage in the Code Behind as well...
Imar
|
I've got it in the code behind, but not in the aspx file.
Also, I did change the class name from Template to $safeitemname$ .
|
|

December 20th, 2008, 06:15 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
The final code you posted looks exactly as it should, doesn't it?
Imar
|
|

December 20th, 2008, 12:16 PM
|
|
Friend of Wrox
|
|
Join Date: Dec 2008
Posts: 119
Thanks: 26
Thanked 0 Times in 0 Posts
|
|
Oh, ok. I thought when you said "You should have Inherits BasePage in the Code Behind as well..."
that I should have had "inherits : BasePage" instead of "inherits : TestPage" in the .aspx file as well.
So it is okay I guess.
Thanks,
Rachel
|
|

December 20th, 2008, 12:57 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Heuh? The Code Behind is just that: the (nested) code file that sits behind the .aspx file.
The book uses "Code Behind" to refer to the code behind, and Markup View to refer to the "code before" of the ASPX page.
Furthermore, the Code Behind class inherits from BasePage. The "code before" class in turn inherits from this class (like TestPage) defined in Code Behind.
Imar
|
|

December 23rd, 2008, 11:05 AM
|
|
Friend of Wrox
|
|
Join Date: Dec 2008
Posts: 119
Thanks: 26
Thanked 0 Times in 0 Posts
|
|
Thanks Imar.
That makes it a little clearer for me.
Rachel
|
|
 |