0

I am making my first website with ASP.net and am having some trouble with the markup for formatting a table. I want to be able to have a user fill out a questionnaire. It is a multi-part questionnaire, so I'm using an accordion to conserve space. One of the questions in the first pane has a five-part answer. My table is giving me some unexpected behavior. About halfway down I attempt to display five labels above five text boxes. I insert these in the proper position in the table, but for some reason they appear at the bottom of the page. I cannot determine what is happening. Any ideas? Thanks in advance.

<%@ Page Title="About Us" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
    CodeFile="Questionnaire.aspx.cs" Inherits="About" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
    <style type="text/css">
        .accordion
        {
            width: 950px;
        }

        .accordionHeader
        {
            border: 1px solid #2F4F4F;
            color: white;
            background-color: #2E4d7B;
            font-family: Arial, Sans-Serif;
            font-size: 12px;
            font-weight: bold;
            padding: 5px;
            margin-top: 5px;
            cursor: pointer;
        }
        .accordionHeaderSelected
        {
            border: 1px solid #2F4F4F;
            color: white;
            background-color: #5078B3;
            font-family: Arial, Sans-Serif;
            font-size: 12px;
            font-weight: bold;
            padding: 5px;
            margin-top: 5px;
            cursor: pointer;
        }

        .accordionContent
        {
            background-color: #D3DEEF;
            border: 1px dashed #2F4F4F;
            border-top: none;
            padding: 5px;
            padding-top: 10px;
        }

        .style1
        {
            width: 100%;
        }
    </style>
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
    <h2>
        Questionnaire
    </h2>
    <p>
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
    </p>
    <p>
    </p>
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
            <asp:Accordion ID="Accordion1" CssClass="accordion" HeaderCssClass="accordionHeader"
                HeaderSelectedCssClass="accordionHeaderSelected" ContentCssClass="accordionContent"
                runat="server" Height="100px" Width="950px">
                <Panes>
                    <asp:AccordionPane ID="AccordionPane2" runat="server">
                        <Header>
                            General Business & Project Question</Header>
                        <Content>
                            <table class="style1">
                                <tr>
                                    <asp:Label ID="lblQid2_1" runat="server"></asp:Label>
                                    <asp:Label ID="lblQ2_1" runat="server"></asp:Label>
                                </tr>
                                <tr>
                                    <asp:TextBox ID="txtQ2_1" runat="server"></asp:TextBox></tr>
                                <tr>
                                    <asp:Label ID="lblQid2_2" runat="server"></asp:Label>
                                    <asp:Label ID="lblQ2_2" runat="server"></asp:Label></tr>
                                <tr>
                                    <asp:TextBox ID="txtQ2_2" runat="server"></asp:TextBox>
                                </tr>
                                <tr>
                                    <asp:Label ID="lblQid2_3" runat="server"></asp:Label>
                                    <asp:Label ID="lblQ2_3" runat="server"></asp:Label></tr>
                                <tr>
                                    <asp:TextBox ID="txtQ2_3" runat="server"></asp:TextBox>
                                </tr>
                                <tr>
                                    <asp:Label ID="lblQid2_4" runat="server"></asp:Label>
                                    <asp:Label ID="lblQ2_4" runat="server"></asp:Label></tr>
                                <tr>
                                    <asp:TextBox ID="txtQ2_4" runat="server"></asp:TextBox>
                                </tr>
                                <tr>
                                    <asp:Label ID="lblQid2_5" runat="server"></asp:Label>
                                    <asp:Label ID="lblQ2_5" runat="server"></asp:Label></tr>
                                <tr>
                                    <asp:TextBox ID="txtQ2_5" runat="server"></asp:TextBox>
                                </tr>
                                <tr>
                                    <asp:Label ID="lblQid2_5_1" runat="server"></asp:Label>
                                    <asp:Label ID="lblQ2_5_1" runat="server"></asp:Label></tr>
                                <tr>
                                    <asp:TextBox ID="txtQ2_5_1" runat="server"></asp:TextBox>
                                </tr>
                                <tr>
                                    <asp:Label ID="lblQid2_5_2" runat="server"></asp:Label>
                                    <asp:Label ID="lblQ2_5_2" runat="server"></asp:Label></tr>
                                <tr>
                                    <asp:TextBox ID="txtQ2_5_2" runat="server"></asp:TextBox>
                                </tr>
                                <tr>
                                    <asp:Label ID="lblQid2_5_3" runat="server"></asp:Label>
                                    <asp:Label ID="lblQ2_5_3" runat="server"></asp:Label></tr>
                                <tr>
                                    <asp:TextBox ID="txtQ2_5_3" runat="server"></asp:TextBox>
                                </tr>
                                <tr>
                                    <asp:Label ID="lblQid2_6" runat="server"></asp:Label>
                                    <asp:Label ID="lblQ2_6" runat="server"></asp:Label></tr>
                                <tr>
                                    <asp:TextBox ID="txtQ2_6" runat="server"></asp:TextBox>
                                </tr>
                                <tr>
                                    <asp:Label ID="lblQid2_7" runat="server"></asp:Label>
                                    <asp:Label ID="lblQ2_7" runat="server"></asp:Label></tr>
                                <tr>
                                    <asp:TextBox ID="txtQ2_7" runat="server"></asp:TextBox>
                                </tr>
                                <tr>
                                    <asp:Label ID="lblQid2_8" runat="server"></asp:Label>
                                    <asp:Label ID="lblQ2_8" runat="server"></asp:Label></tr>
                                <tr>
                                    <td>
                                        <asp:Label ID="Label1"  Text="test" runat="server"></asp:Label>
                                    </td>
                                    <td>
                                        <asp:Label ID="Label2" runat="server"></asp:Label>
                                    </td>
                                    <td>
                                        <asp:Label ID="Label3" runat="server"></asp:Label>
                                    </td>
                                    <td>
                                        <asp:Label ID="Label4" runat="server"></asp:Label>
                                    </td>
                                    <td>
                                        <asp:Label ID="Label5" runat="server"></asp:Label>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <asp:TextBox ID="txtQ2_8" runat="server"></asp:TextBox>
                                    </td>
                                    <td>
                                        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
                                    </td>
                                    <td>
                                        <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
                                    </td>
                                    <td>
                                        <asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
                                    </td>
                                    <td>
                                        <asp:TextBox ID="TextBox4" runat="server"></asp:TextBox>
                                    </td>
                                </tr>
                                <tr>
                                    <asp:Label ID="lblQid2_9" runat="server"></asp:Label>
                                    <asp:Label ID="lblQ2_9" runat="server"></asp:Label></tr>
                                <tr>
                                    <asp:TextBox ID="txt2_9" runat="server"></asp:TextBox>
                                </tr>
                                <tr>
                                    <asp:Label ID="lblQid2_10" runat="server"></asp:Label>
                                    <asp:Label ID="lblQ2_10" runat="server"></asp:Label></tr>
                                <tr>
                                    <asp:TextBox ID="txtQ2_10" runat="server"></asp:TextBox>
                                </tr>
                                <tr>
                                    <asp:Label ID="lblQid2_11" runat="server"></asp:Label>
                                    <asp:Label ID="lblQ2_11" runat="server"></asp:Label></tr>
                                <tr>
                                    <asp:RadioButton ID="rboQ2_11y" Text="Yes" runat="server" AutoPostBack="True" GroupName="a"
                                        OnCheckedChanged="rboQ2_11y_CheckedChanged" />
                                    <asp:RadioButton ID="rboQ2_11n" Text="No" runat="server" AutoPostBack="True" GroupName="a"
                                        OnCheckedChanged="rboQ2_11n_CheckedChanged" /></tr>
                                <tr>
                                    <asp:Label ID="lblQid2_11_1" runat="server"></asp:Label>
                                    <asp:TextBox ID="txtQ2_11_1" runat="server"></asp:TextBox>
                                </tr>
                            </table>
                        </Content>
                    </asp:AccordionPane>
                    <asp:AccordionPane ID="AccordionPane3" runat="server">
                        <Header>
                            Solution Architecture & Technical Questions</Header>
                        <Content>
                            <table class="style1">
                                <tr>
                                    <asp:CheckBox ID="chb_1" runat="server" Text="Testing" /></tr>
                            </table>
                        </Content>
                    </asp:AccordionPane>
                </Panes>
            </asp:Accordion>
        </ContentTemplate>
    </asp:UpdatePanel>
    <p>
        <asp:Button ID="btnSave" runat="server" Text="Save" OnClick="btnSave_Click" />
        <asp:Label ID="lblError" runat="server" Text=""></asp:Label>
    </p>
    <p>
</asp:Content>
Luiggi Mendoza
  • 85,076
  • 16
  • 154
  • 332
MCR
  • 1,633
  • 3
  • 21
  • 36

2 Answers2

3

You need to fix this:

<tr>
    <asp:Label ID="lblQid2_1" runat="server"></asp:Label>
    <asp:Label ID="lblQ2_1" runat="server"></asp:Label>
</tr>

For this on every line you have <tr> tags:

<tr>
    <td>
        <asp:Label ID="lblQid2_1" runat="server"></asp:Label>
        <asp:Label ID="lblQ2_1" runat="server"></asp:Label>
    <td>
</tr>

Or this, it depends on how many columns (<td>) per row (<tr>) you need:

<tr>
    <td>
        <asp:Label ID="lblQid2_1" runat="server"></asp:Label>
    </td>
    <td>
        <asp:Label ID="lblQ2_1" runat="server"></asp:Label>
    <td>
</tr>

Hope it helps!

Luis
  • 5,786
  • 8
  • 43
  • 62
2

your html table have <tr> table rows but no <td> table columns this might be the reason of your labels and textboes moving at the bottom of the page

HatSoft
  • 11,077
  • 3
  • 28
  • 43