Hello,
I was given a copy of this book by a friend in order to get me up to scratch on ASP.NET. So far I’ve created a new ASP.NET Web Site using Visual C# and saved it in “C:\LearningASP\CS\”
Now I’m on page 14 chapter one were the book states:
The main panel in the Visual Web Developer interface is the page editor, in which you’ll see the HTML source of the Default.aspx web page. Edit the title of the page to something more specific than Home Page, such as Welcome to Build Your Own ASP.NET 4 Website!:
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
[B]<title>Welcome to Build Your Own ASP.NET 4 Website!
</title>[/B]
</head>
The book’s bold type implies that this is code we are editing rather than an entire new piece of code however in Default.aspx there isn’t any <html> tags present. My Default.aspx looks like this:
<%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
CodeFile="Default.aspx.cs" Inherits="_Default" %>
<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
<h2>
Welcome to ASP.NET!
</h2>
<p>
To learn more about ASP.NET visit <a href="http://www.asp.net" title="ASP.NET Website">www.asp.net</a>.
</p>
<p>
You can also find <a href="http://go.microsoft.com/fwlink/?LinkID=152368&clcid=0x409"
title="MSDN ASP.NET Docs">documentation on ASP.NET at MSDN</a>.
</p>
</asp:Content>
But the book implies that I am editing a title tag within html tags that already exist with “Home Page” as the content, I can’t find this anywhere in the project. So I tried replacing the entire Default.aspx file with the code in the book but then the output differs from figure 1.12.
The code included with the book is different again:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Welcome to Build Your Own ASP.NET 3.5 Web Site!</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<p>Hello there!</p>
<p>
The time is now:
<asp:Label ID="myTimeLabel" runat="server" />
</p>
</div>
</form>
</body>
</html>
There’s no instruction to strip down the header from:
<%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
CodeFile="Default.aspx.cs" Inherits="_Default" %>
To:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
Note: I’m using Visual Studio 2010 and not Visual Studio Web Express.