我有一个包含 Div 和各种服务器控件(如 DropDownList )的 Web 内容表单。当我运行应用程序时,它运行良好,没有任何错误,但是当我查看 HTML 源代码时,服务器控件带有红色下划线。将鼠标移到 DropDownList 上时,会显示工具提示警告:

DropDownList is not a known element. This can occur if there is a compilation error in a website.

已编辑
<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="contentReportSchemesMenu.aspx.cs" Inherits="contentReportMenu" Title="Reports Menu" %>

<asp:Content ID="ContentReportMenu" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <div id="divMenu" class="divMenu" runat="server">
        <table id="tblMenuLayout" class="Options" runat="server">
        <tr>
            <td colspan="2" class="Top">Scheme Reports Menu</td>
            <td></td>
        </tr>
            <tr>
                <td class="Left">Report Type</td>
                <td class="Right">
                        &nbsp;<asp:DropDownList ID="ddlReportType" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddlReportType_SelectedIndexChanged"></asp:DropDownList>
                </td>
            </tr>
            <tr>
                <td class="Left">Select District</td>
                <td class="Right">
                        &nbsp;<asp:DropDownList ID="ddlDistrict" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddlDistrict_SelectedIndexChanged" Enabled="False"></asp:DropDownList>
                </td>
            </tr>
            <tr>
                <td class="Left">Select Block</td>
                <td class="Right">
                    &nbsp;<asp:DropDownList ID="ddlBlock" runat="server" AutoPostBack="true" Enabled="False" OnSelectedIndexChanged="ddlBlock_SelectedIndexChanged"></asp:DropDownList>
                </td>
            </tr>
            <tr>
                <td colspan="2" style="text-align:center">
                    <asp:Button ID="btnSubmit" runat="server" Text="Submit" OnClick="btnSubmit_Click" Enabled="False" />
                    &nbsp;</td>
                <td></td>
            </tr>
        </table>
    </div>
</asp:Content>

最佳答案

快速的谷歌搜索很快找到了解决方案:从“C:\Documents and Settings[用户名]\Application Data\Microsoft\VisualStudio\9.0\ReflectedSchemas”文件夹(或“...\VisualStudio\8.0\...”如果运行 Visual Studio 2005)在 Windows XP 中。在 Windows 7 中,它位于“C:\Users{User Profile}\AppData\Roaming\Microsoft...etc”下。还要记住,路径的“VisualStudio”部分将根据安装的版本而有所不同。

我关闭了 Visual Studio(对于会影响 IDE 的更改总是一个好主意),删除文件然后重新打开项目。警告消失了。

我在以下位置找到了对此解决方案的引用:
http://forums.asp.net/t/1205528.aspx
http://blogs.msdn.com/mikhailarkhipov/archive/2005/04/21/410557.aspx

仅供引用,我在 Google 中使用的搜索词是“不支持元素”。

我不知道为什么会发生这种情况,但我知道在网络环境中发生了一些 flakey 域配置文件的事情。

10-08 00:20