error in simple example

Discussion in 'ASP .Net' started by Ming Zhu, Jul 7, 2003.

  1. Ming Zhu

    Ming Zhu Guest

    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\Anchor.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
    }
    }
    --------------------------------------------------------------------------------
    Ming Zhu, Jul 7, 2003
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Doug
    Replies:
    1
    Views:
    388
  2. Simon Biber
    Replies:
    27
    Views:
    765
    ┬Ča\\/b
    Dec 1, 2006
  3. David Williams
    Replies:
    2
    Views:
    479
    David Williams
    Nov 29, 2005
  4. Samuel
    Replies:
    6
    Views:
    396
    Samuel
    May 24, 2007
  5. Sam Roberts
    Replies:
    15
    Views:
    278
    Sam Roberts
    Feb 7, 2005
Loading...

Share This Page