By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,368 Members | 1,706 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,368 IT Pros & Developers. It's quick & easy.

error in simple example

P: n/a
Hi, all,

I'm new to .NET and ASP.NET. I only use .NET Framework 1.0. I'm
reading the book "C# developer's guide to ASP.NET". But I find there
is no place to download the code used inside this book.

Anyway, my problem is the following example doesn't work. It's a
simple page using HTML control Anchor. But I meet the following
error. Is it because it requires some new features provided only by
..NET Framework 1.1? Who can tell me why and how to solve it. Thanks
a lot!

Server Error in '/CsGuildeToASP' Application.
--------------------------------------------------------------------------------

Parser Error
Description: An error occurred during the parsing of a resource
required to service this request. Please review the following specific
parse error details and modify your source file appropriately.

Parser Error Message: Could not load type 'HtmlControls.Anchor'.

Source Error:
Line 1: <%@ Page language="c#" Codebehind="Anchor.aspx.cs"
AutoEventWireup="false" Inherits="HtmlControls.Anchor" %>
Line 2: <!DOCTPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
Line 3: <html>
Source File: D:\ZM\Study\Microsoft\CsGuildeToASP\Chapter2\Ancho r.aspx
Line: 1
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:1.0.3705.288;
ASP.NET Version:1.0.3705.288

The following is the ASP.NET page file, Anchor.aspx.
--------------------------------------------------------------------------------
<%@ Page language="c#" Codebehind="Anchor.aspx.cs"
AutoEventWireup="false" Inherits="HtmlControls.Anchor" %>
<!DOCTPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Dynamically Generated Anchor</title>
<meta name="GENERATOR" Content="Micorosoft Visual Studio 7.0">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" Content="JavaScript">
<meta name="vs_targetSchema"
Content="http://schemas.microsoft.com/intellisense/ie5">
</head>

<body>
<form id="Anchor" method="post" runat="server">
<a id="AnchorTag" runat="server">Test Anchor</a>
</form>
</body>
</html>
--------------------------------------------------------------------------------
The following is the code file, Anchor.aspx.cs.
--------------------------------------------------------------------------------
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

namespace HtmlControls
{
public class Anchor : System.Web.UI.Page
{
protected System.Web.UI.HtmlControls.HtmlAnchor AnchorTag;

private void Page_Load(object sender, System.EventArgs e) {
if( Page.Request.IsSecureConnection) {
AnchorTag.HRef = "https://www.deeptraining.com";
AnchorTag.InnerText = "Secure Link";
} else {
AnchorTag.HRef = "http://www.deeptraining.com";
AnchorTag.InnerText = "Unsecure Link";
}
}

#region Web From Designer generated code
override proctected void OnInit(EventArgs e) {
//
// CODEGEN: This call is required by the ASP.NET Web Form
Designer.
//
InitializeComponent();
base.OnInit(e);
}

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent() {
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
}
}
--------------------------------------------------------------------------------
Nov 17 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.