开发者

Why server controls are underlined when placed inside Content tags?

开发者 https://www.devze.com 2023-04-12 22:39 出处:网络
I have a Web Content Form containing a Div and various Server controls like DropDownList. When I run the application, it runs well without any errors, but when I view the HTML source, the Server contr

I have a Web Content Form containing a Div and various Server controls like DropDownList. When I run the application, it runs well without any errors, but when I view the HTML source, the Server controls are red underlined. On bringing the mouse over, say, DropDownList, a tooltip warning is displayed:

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

Edited

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

<asp:Content ID="ContentReportMenu" ContentPlaceHolderID="ContentPla开发者_高级运维ceHolder1" 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>


A quick Google search soon found the solution: Delete the files from “C:\Documents and Settings[Username]\Application Data\Microsoft\VisualStudio\9.0\ReflectedSchemas” folder (or “…\VisualStudio\8.0\…” if running Visual Studio 2005) in Windows XP. In Windows 7 it is under "C:\Users{User Profile}\AppData\Roaming\Microsoft...etc". Remember also the "VisualStudio" part of the path will be different depending on the version installed.

I closed Visual Studio (always a good ideas for changes that will affect the IDE), deleted the files then re-opened the project. The warnings were gone.

I found references to this solution at: http://forums.asp.net/t/1205528.aspx http://blogs.msdn.com/mikhailarkhipov/archive/2005/04/21/410557.aspx

FYI, the search term I used in Google was “element is not supported”.

I don't know why this happens but I do know there are some flakey domain profile things happening in the network environmnet.


You're receiving this error because the table is running at the server, but the tr and td elements are not. When you specify runat="server" on a table element, it expects child elements to run at the server as well.

There are two easy ways to verify this:

  1. Remove runat="server" from the table declaration;
  2. Take the DropDownList(s) outside of the table

Try one of these two options, and see if it fixes the problem.

EDIT

Make sure that the ContentPlaceHolderID on the content form matches the ID of the corresponding content area in the master page. If that doesn't fix your problem, try creating a new content form, applying the advice above, and add a control to the form in the content area. If there are no errors, then you know the issue is somewhere in your markup.


Try deleting the schema cache. To do this, close Visual Studio and delete all of the files in the following directory:

C:\Users\USERNAME\AppData\Roaming\Microsoft\VisualStudio\10.0\ReflectedSchemas

Once the files have been deleted, open Visual Studio again and the problem should be fixed.


You said that "when I view the HTML source, the Server controls are red underlined", but HTML source can not contains such elements like DropDownList because this is the ASP.NET control which is generated as HTML Select tag. Considering that common solution with schema cleanup is not helped you perhaps a problem is in an other place... I'll try to assume that you are opening ASPX/ASCX file itself using some third party editor which is not aware of ASP.NET controls, am I right?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号