0

我正在使用 ASP.net 创建我的第一个网站,并且在格式化表格的标记方面遇到了一些问题。我希望能够让用户填写问卷。这是一个多部分的问卷,所以我使用手风琴来节省空间。第一个窗格中的一个问题有一个由五部分组成的答案。我的桌子给了我一些意想不到的行为。大约一半时,我尝试在五个文本框上方显示五个标签。我将它们插入表格中的适当位置,但由于某种原因,它们出现在页面底部。我无法确定发生了什么。有任何想法吗?提前致谢。

<%@ 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>
4

2 回答 2

3

你需要解决这个问题:

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

为此,您在每一行都有<tr>标签:

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

或者,这取决于您需要<td>每行 ( ) 有多少列 ( ) :<tr>

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

希望能帮助到你!

于 2012-07-12T23:11:50.623 回答
2

您的 html 表格有<tr> table rows but no <td> table columns 这可能是您的标签和文本在页面底部移动的原因

于 2012-07-12T23:11:45.530 回答