简体   繁体   中英

Need to wrap table rows and controls in an ASP.NET webform

Here's my table:

  <table class="detailTable">
        <tr>
            <th>
                Event Title:
            </th>
            <td>
                <asp:Label ID="lblTitle" runat="server"></asp:Label>
            </td>
        </tr>
        <tr>
            <th>
                Date:
            </th>
            <td>
                <asp:TextBox ID="txtDate" runat="server"></asp:TextBox>
            </td>
        </tr>
        <tr>
            <th>
                Begin Time:
            </th>
            <td>
                <asp:TextBox ID="txtBeginTime" runat="server"></asp:TextBox>
            </td>
        </tr>
        <tr>
            <th>
                End Time:
            </th>
            <td>
                <asp:TextBox ID="txtEndTime" runat="server"></asp:TextBox>
            </td>
        </tr>
        <!-- I need to wrap these last two rows in some kind of server control -->
        <tr>
            <th>
                Duration:
            </th>
            <td>
                <asp:TextBox ID="txtHours" runat="server"></asp:TextBox>
                :
                <asp:TextBox ID="txtMins" runat="server"></asp:TextBox>
            </td>
        </tr>
        <tr>
            <th>
                Concurrency:
            </th>
            <td>
                <asp:TextBox ID="txtConcurrency" runat="server"></asp:TextBox>
            </td>
        </tr>
    </table>

As the comment states, I need to wrap the last two rows in some kind of control so that I can conditionally hide them on the server side.

I know that I can add runat="server" to the rows and hide them individually, but I don't want to do that. I also don't want to hide them client side. A panel would be good, but it renders a div, making the HTML invalid. TBODY with runat="server" is invalid also. The Literal control can't contain other controls, so it's out.

Is there a control that I am missing that will accomplish this? I basically need a Panel control that renders only what it contains and nothing more. Is there a way to change the panel control so that it doesn't render a wrapping div?

What about a placeholder control?

That's what it is designed for.

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