使asp列表框的宽度与tablecell的宽度相同

时间:2014-12-10 19:49:48

标签: c# asp.net

我有一个包含2行和4个单元格的表格。第一和第二格子的桌子宽度为30%,第三和第二格子的宽度为30%,总长度为90%。

我尝试将列表框单元格放入面板并将其宽度设置为30%,将单元格宽度设置为30%以及其他一些东西,但宽度仍然被忽略。

表格本身应为屏幕宽度的100%。 enter image description here

我的列表框继续扩展到超过他们分配的30%,但我怎么能阻止它呢?

更新:我让列表框停止溢出,但列表框有时小于单元格 - 我可以让它始终匹配单元格宽度,无论文本是短还是长于宽度?

<div style="overflow: hidden">
<asp:Table runat="server" Width="100%" GridLines="Horizontal">
    <asp:TableRow Width="100%">
        <asp:TableCell RowSpan="2">
            <asp:ListBox ID="JsonAppKeyListBox" runat="server" AutoPostBack="True" Rows="20" BackColor="#66CCFF" ForeColor="White" onselectedindexchanged="JsonListBox_SelectedIndexChanged">
            </asp:ListBox>
        </asp:TableCell>
        <asp:TableCell RowSpan="2">
            <asp:Panel ID="pnlParentNodes" runat="server" Width="100%">
                <asp:ListBox ID="JsonAppsValueListBox" runat="server" AutoPostBack="True" Rows="20" BackColor="#66CCFF" ForeColor="White" Width="100%">
                </asp:ListBox>
            </asp:Panel>
        </asp:TableCell>
        <asp:TableCell HorizontalAlign="Right" Width="30%">
             <asp:ImageButton ID="imgBtnBack" runat="server" ImageUrl="~/img/analysis/analysis_back_logo.png" Width="30px" HorizontalAlign="Center"/>
             <asp:ImageButton ID="imgBtnDelete" runat="server" ImageUrl="~/img/analysis/analysis_delete_logo.png" Width="30px"/>
            <asp:ImageButton ID="imgBtnConfirm" runat="server" ImageUrl="~/img/analysis/analysis_confirmed_logo.png" Width="30px"/>
        </asp:TableCell>
    </asp:TableRow>
    <asp:TableRow>
        <asp:TableCell>
            <asp:TextBox ID="tb_nodeNotes" runat="server" Height="300px" Width="100%" BackColor="#66CCFF" ForeColor="White" Rows="30" TextMode="MultiLine">
            </asp:TextBox>
        </asp:TableCell>
    </asp:TableRow>
</asp:Table>
</div>

1 个答案:

答案 0 :(得分:0)

得到了它。需要将列表框,单元格和行分别设置为30%,30%和100%

<div style="overflow: hidden">
<asp:Table runat="server" Width="100%" GridLines="Horizontal">
    <asp:TableRow Width="100%">
        <asp:TableCell RowSpan="2" Width="30%">
            <asp:ListBox ID="JsonAppKeyListBox" runat="server" AutoPostBack="True" Rows="20" BackColor="#66CCFF" ForeColor="White" onselectedindexchanged="JsonListBox_SelectedIndexChanged" Width="100%">
            </asp:ListBox>
        </asp:TableCell>
        <asp:TableCell RowSpan="2" Width="30%">
                <asp:ListBox ID="JsonAppsValueListBox" runat="server" AutoPostBack="True" Rows="20" BackColor="#66CCFF" ForeColor="White" Width="100%" Height="100%">
                </asp:ListBox>

        </asp:TableCell>
        <asp:TableCell HorizontalAlign="Right" Width="30%">
             <asp:ImageButton ID="imgBtnBack" runat="server" ImageUrl="~/img/analysis/analysis_back_logo.png" Width="30px" HorizontalAlign="Center"/>
             <asp:ImageButton ID="imgBtnDelete" runat="server" ImageUrl="~/img/analysis/analysis_delete_logo.png" Width="30px"/>
            <asp:ImageButton ID="imgBtnConfirm" runat="server" ImageUrl="~/img/analysis/analysis_confirmed_logo.png" Width="30px"/>
        </asp:TableCell>
    </asp:TableRow>
    <asp:TableRow>
        <asp:TableCell>
            <asp:TextBox ID="tb_nodeNotes" runat="server" Height="300px" Width="100%" BackColor="#66CCFF" ForeColor="White" Rows="30" TextMode="MultiLine">
            </asp:TextBox>
        </asp:TableCell>
    </asp:TableRow>
</asp:Table>
</div>