Halvard
Halvard

Reputation: 4003

BC30311 error: Why can't I use a PlaceHolder inside a table for a specific user control?

We have a standard asp.net web application and have used asp:PlaceHolders in multiple places. In some files we get this error message during runtime:

BC30311: Value of type 'System.Web.UI.WebControls.PlaceHolder' cannot be converted to 'System.Web.UI.HtmlControls.HtmlTableRow'.

Why?

If I remove the place holder the page renders just fine.

Here is the html (simplified version):

<table runat="server" id="tblExtradata" visible=true>               
  <asp:PlaceHolder ID="test" runat="server" Visible="true">
    <tr>
      <td>
        <asp:Label ID="lblExpenses" runat="server" Text="Expensesr"></asp:Label>
      </td>
    </tr>
  </asp:PlaceHolder>
</table>

Version Information: Microsoft .NET Framework Version:2.0.50727.5446; ASP.NET Version:2.0.50727.5420

Upvotes: 2

Views: 3105

Answers (1)

James Johnson
James Johnson

Reputation: 46047

Because you're running the table at the server, it expects only table elements nested within. If you take the runat="server out of the table, it should work fine.

Upvotes: 3

Related Questions