Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > error in simple example

Reply
Thread Tools

error in simple example

 
 
Ming Zhu
Guest
Posts: n/a
 
      07-07-2003
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
}
}
--------------------------------------------------------------------------------
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Simple omniORBpy example throws exception with error 0x41540002 Samuel Python 6 05-24-2007 10:41 AM
Error in scanf implementation or error in example in standard? Simon Biber C Programming 27 12-01-2006 04:56 PM
Simple example of error handling using base class inheritance? Doug ASP .Net 1 07-03-2006 09:07 PM
Compiler error with nested templates (simple example included) David Williams C++ 2 11-29-2005 09:34 PM
'example.com' == 'example.com.' => false... is this intended? Sam Roberts Ruby 15 02-07-2005 04:36 PM



Advertisments