简体   繁体   中英

User controls error (VS2012)

I keep getting an error message saying that "The element 'PriceTable' is not a known element.

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

This error shows only if I use GridView. For example if I do this:

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

And the ascx file that causes trouble looks like this:

<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>

However... If I change the ascx file to use a table, (looking like the below code), then it works fine, and VS does not complain about any unknown element. I have tried rebuild solution and restart VS, but no luck.

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

Any idea on what it might be?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM