Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why server controls are underlined when placed inside Content tags?

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="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>
like image 852
RKh Avatar asked Feb 23 '23 17:02

RKh


2 Answers

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.

like image 150
sikender Avatar answered Apr 28 '23 04:04

sikender


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.

like image 22
James Johnson Avatar answered Apr 28 '23 03:04

James Johnson