NoBullMan
NoBullMan

Reputation: 2184

aspnet table row

I am trying to add a table in aspx page and need to have access to the table cells in .cs file. Created AspNet:Table with some rows and cells but keep getting 'not a valid identifier' error and can't see why:

<asp:Table runat="server" ID="tblStatus" Width="920" CellPadding="0" CellSpacing="0">
    <asp:TableRow>
        <asp:TableCell runat="server" ID="LM6-D7-L"></asp:TableCell>

At the table cell row, I get:

Build (web): 'LM6-D7-L' is not a valid identifier.
Build (web): Literal content ('</asp:TableCell>') is not allowed within a 'System.Web.UI.WebControls.TableCellCollection'.

This happens for every row in the table.

Upvotes: 0

Views: 918

Answers (2)

Ricardo Souza
Ricardo Souza

Reputation: 16446

ASP.NET doesn't accept an identifiers with dashes in. You have to change the dashes to underscores or something else:

 <asp:TableCell runat="server" ID="LM6_D7_L"></asp:TableCell> 

Or:

 <asp:TableCell runat="server" ID="LM6D7L"></asp:TableCell> 

Etc.

Upvotes: 1

Erik Funkenbusch
Erik Funkenbusch

Reputation: 93424

ASP.NET does not allow hyphens in server controls ID's. It's perfectly valid for non-server controls (those that do not have runat="server" on them) but asp.net is more picky.

Upvotes: 1

Related Questions