【问题标题】:RadioButtonList alignment issueRadioButtonList 对齐问题
【发布时间】:2015-03-16 20:39:28
【问题描述】:

我有一个基于后端值的以下代码,我必须在 aspx 页面中显示单选按钮列表列表项值和控件。

当 rbl1.SelectedValue = "0" 控件的 alignmnet 很好。 当 rbl1.SelectedValue = "1" RadioButtonList 像下面一样居中,我希望这个 rbl 只对齐左侧。

任何人都可以帮助我吗?

  • C#:

    public string HiddenClassName { get; private set; }
    if (!string.IsNullOrEmpty(value) && value.ToLower() == "y")
    {
        rbl1.SelectedValue = "0"; //Yes                 
        lblName.Visible = true;
        txtName.Visible = true;               
        HiddenClassName = "display:block";
    }
    else
    {
        rbl1.SelectedValue = "1"; //No
        lblName.Visible = false;
        txtName.Visible = false;
        HiddenClassName = "display:none";
    }
    
  • ASPX:

        <h2>
             Information</h2>
        <table width="100%">
            <tr>
                <td>
                    <asp:Label ID="lbl1" runat="server" Width="180px" Text="Would like to use?"></asp:Label>
                </td>
                <td >
                    <asp:RadioButtonList ID="rbl1" runat="server" TextAlign="Right" RepeatDirection="Horizontal">
                        <asp:ListItem Value="Yes" Text="Yes" Selected="True" />
                        <asp:ListItem Value="No" Text="No" />
                    </asp:RadioButtonList>
                </td>
                <td style="padding-bottom: 17px">
                        <%=this.ShowHelp("rbl_Help")%>
                    </td>
              <%--  <asp:Panel ID="pnlAgntName" runat="server">  --%>                      
                    <td align="right">
                        <asp:Label ID="lblName" Text="Name" runat="server"></asp:Label>
                    </td>
                    <td align="left">
                        <asp:TextBox ID="txtName" runat="server"></asp:TextBox>
                    </td>
                    <td  style="<%= HiddenClassName %>;padding-bottom: 17px">
                        <%=this.ShowHelp("Name_Help")%>
                    </td>
                <%--</asp:Panel>--%>
            </tr>               
        </table>
        <div class="hr">
        </div>
    </fieldset>
    

【问题讨论】:

    标签: c# html asp.net


    【解决方案1】:

    在每个 td 中添加宽度,例如 style="width: 25px"

    【讨论】:

      猜你喜欢
      • 2014-04-10
      • 1970-01-01
      • 2011-10-31
      • 2011-06-16
      • 1970-01-01
      • 1970-01-01
      • 2013-01-07
      • 1970-01-01
      相关资源
      最近更新 更多