asp.net – 元素’ToolkitScriptManager’不是已知元素

前端之家收集整理的这篇文章主要介绍了asp.net – 元素’ToolkitScriptManager’不是已知元素前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
所以我有一个名为WebParts.aspx的文件,看起来像这样 –
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebParts.aspx.cs" Inherits="e.WebParts" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>

<!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></title>
</head>
<body>
  <form id="form1" runat="server">


    <asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
    </asp:ToolkitScriptManager>

    <div>
      <asp:TabContainer ID="TabContainer1" runat="server">


      <asp:TabPanel ID="TabPanel1" runat="server">
      <ContentTemplate>Page One</ContentTemplate>
      </asp:TabPanel>

      <asp:TabPanel ID="TabPanel2" runat="server">
      <ContentTemplate>Page Two</ContentTemplate>
      </asp:TabPanel>

      <asp:TabPanel ID="TabPanel3" runat="server">
      <ContentTemplate>Page Three</ContentTemplate>
      </asp:TabPanel>

      </asp:TabContainer>
  </div>
  </form>
</body>
</html>

这样就可以在标签容器中创建3个标签面板.

但是,当我更改该页面以使用MasterPage.master看起来像这样 –

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebParts.aspx.cs" Inherits="eservice.WebParts"  MasterPageFile="~/MasterPage.Master"%>

<asp:Content ID="Content2"  
  ContentPlaceHolderID="ContentPlaceHolder1" 
  runat="server">

  <asp:LoginView ID="LoginView1" runat="server">
    <LoggedInTemplate>
       <p id="backtoblog"></p>
       <p> Preferences</p>
        <div>


    <asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
    </asp:ToolkitScriptManager>

    <div>
      <asp:TabContainer ID="TabContainer1" runat="server">


      <asp:TabPanel ID="TabPanel1" runat="server">
      <ContentTemplate>Page One</ContentTemplate>
      </asp:TabPanel>

      <asp:TabPanel ID="TabPanel2" runat="server">
      <ContentTemplate>Page Two</ContentTemplate>
      </asp:TabPanel>

      <asp:TabPanel ID="TabPanel3" runat="server">
      <ContentTemplate>Page Three</ContentTemplate>
      </asp:TabPanel>

      </asp:TabContainer>
  </div>
   </div>
  </LoggedInTemplate>
    <AnonymousTemplate>
      You are not logged in.
      <br />
      Please login to access eservice
    </AnonymousTemplate>
  </asp:LoginView>

  </asp:Content>

VS2008给了我以下警告:

Element ‘ToolkitScriptManager’ is not
a known element. This can occur if
there is a compilation error in the
Web site,or the web.config file is
missing.

在以下行:

<asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">

解决方法

您的第二个文件不包含该行
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>

你在第一个文件中有.仅仅因为母版页知道了asp:前缀以及与之关联的程序集/命名空间,并不意味着子页面会这样做.

更好的方法是在web.config中注册程序集/名称空间/标记前缀,如下所示:

<configuration>
    <!-- ... -->
    <system.web>
        <!-- ... -->
        <pages>
            <controls>
                <add tagPrefix="asp"
                     namespace="AjaxControlToolkit"
                     assembly="AjaxControlToolkit" />
            </controls>
        </pages>
    </system.web>
</configuration>

猜你在找的asp.Net相关文章