用户控制错误(VS2012)

时间:2014-02-14 00:59:16

标签: asp.net gridview user-controls

我不断收到一条错误消息,指出“元素'PriceTable'不是已知元素。

<%@ Register Src="~/WebControls/PriceTable.ascx" TagPrefix="uc1" TagName="PriceTable" %>

仅当我使用GridView时才会显示此错误。例如,如果我这样做:

<div class="TextDiv">
    <b>General info</b>
    <uc1:PriceTable runat="server" id="PriceTable" />
    <p>
        Some text
    </p>
</div>

导致问题的ascx文件如下所示:

<asp:Panel ID="PriceTable" runat="server" class="FullScreenGrid">
    <asp:GridView ID="PriceTableGridView" runat="server" AutoGenerateColumns="false" DataSource="information">
        <Columns>
            <asp:TemplateField HeaderText="Dyr">
                <ItemTemplate>
                    <asp:Literal ID="animalCol" runat="server" Text='<%# Eval("Beskrivelse") %>' />
                </ItemTemplate>
            </asp:TemplateField>

            <asp:TemplateField HeaderText="Pris excl. moms (Gælder fra 1. april 2014)">
                <ItemTemplate>
                    <asp:Literal ID="priceCol" runat="server" Text='<%# Eval("Amount") %>' />
                </ItemTemplate>
            </asp:TemplateField>
        </Columns>

    </asp:GridView>

</asp:Panel>

...然而 如果我更改ascx文件以使用表(看起来像下面的代码),那么它工作正常,VS不会抱怨任何未知元素。我尝试过重建解决方案并重启VS,但没有运气。

<table id="PriceTableTemp" class="FullScreenGrid" style="width: auto; margin: 10px 0px">
<tr>
    <th>Dyr</th>
    <th>Pris excl. moms </th>
</tr>

对它可能是什么有任何想法?

1 个答案:

答案 0 :(得分:0)

重建并重启VS几次修复它,即使它没有意义