Typen 'alliancepages.treeviewarticle.onlinedemo' kunne ikke
Når jeg prøver at køre et eksempel fra alliancepages får jeg denne fejl:Typen 'alliancepages.treeviewarticle.onlinedemo' kunne ikke indlæses.
Her er koden:
onlinedemo.aspx:
<%@ Page Language="c#" codebehind="onlinedemo.aspx.cs" autoeventwireup="false" Inherits="alliancepages.treeviewarticle.onlinedemo" %>
<%@ Register TagPrefix="iewc" Namespace="Microsoft.Web.UI.WebControls" Assembly="Microsoft.Web.UI.WebControls, Version=1.0.2.226, Culture=neutral, PublicKeyToken=31bf3856ad364e35" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<html>
<head>
<title>onlinedemo</title>
<meta content="Microsoft Visual Studio 7.0" name="GENERATOR" />
<meta content="C#" name="CODE_LANGUAGE" />
<meta content="JavaScript" name="vs_defaultClientScript" />
<meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema" />
</head>
<body>
<form id="onlinedemo" method="post" runat="server">
<IEWC:TREEVIEW id="TreeView1" runat="server" SelectExpands="True" AutoPostBack="True"></IEWC:TREEVIEW>
</form>
</body>
</html>
onlinedemo.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;
using System.Data.OleDb;
using System.Xml;
using System.Xml.Xsl;
using System.IO;
using System.Xml.XPath;
namespace alliancepages.treeviewarticle
{
/// <summary>
/// Summary description for onlinedemo.
/// </summary>
public class onlinedemo : System.Web.UI.Page
{
protected Microsoft.Web.UI.WebControls.TreeView TreeView1;
private void Page_Load(object sender, System.EventArgs e)
{
if(!Page.IsPostBack)
{
BindView();
}
}
private void BindView()
{
//Connection to database
OleDbConnection objConn=new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath("db.mdb") + ";Persist Security Info=False");
//SQL query to get data from CATEGORIES table
OleDbCommand objCommand=new OleDbCommand("SELECT * FROM CATEGORIES",objConn);
//OleDbDataAdapter
OleDbDataAdapter objDa =new OleDbDataAdapter(objCommand);
//DataSet
DataSet ds=new DataSet("CATEGORIESDS");
//Fill DataSet
objDa.Fill(ds ,"CATEGORIES");
//Create DataRelation
DataRelation drel=new DataRelation("CATEGORIES_RECURSIVE",ds.Tables["CATEGORIES"].Columns["CategoryID"],ds.Tables["CATEGORIES"].Columns["ParentCategoryID"]);
//Make sure relation is nested
drel.Nested =true;
//Add relation to DataSet's Relations collection
ds.Relations.Add(drel);
//XmlDocument to hold XML generated from DataSet
XmlDocument objDoc=new XmlDocument();
//Load XML
objDoc.LoadXml(ds.GetXml());
//Create XslTransform object
XslTransform objXSL=new XslTransform();
//Load XSLT stylesheet
objXSL.Load(Server.MapPath("transformationtemplate.xslt"));
//StringWriter to temporarily hold result of the transformation
StringWriter writer=new StringWriter();
//Apply transformation with no arguments and dump results to StringWriter.
objXSL.Transform(objDoc.CreateNavigator(),null,writer);
//Set TreeView's TreeNodeSrc property to get XML from StringWriter.
TreeView1.TreeNodeSrc =writer.ToString();
//Bind TreeView
TreeView1.DataBind();
//Close StringWriter
writer.Close();
}
#region Web Form Designer generated code
override protected 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
}
}
Hvad kan der være galt?
Jeg har installeret IE webcontrols
