让RadioButtonList 像Tab菜单控件一样显示

 引用的CSS

.radiobuttonlist
{
    font: 12px Verdana, sans-serif;
    color: #000; /* non selected color */
}
 
.radiobuttonlist input
{
    width: 0px;
    height: 0px;
}
.radiobuttonlist label
{
    color: #3E3928;
    background-color:#E8E5D4;
    padding-left: 6px;
    padding-right: 6px;
    padding-top: 2px;
    padding-bottom: 2px;
    border: 1px solid #AAAAAA;
    margin: 0px 0px 0px 0px;
    white-space: nowrap;
    clear: left;
    margin-right: 5px;
}
.radiobuttonlist span.selectedradio label
{
    background-color: #F7F5E8;
    color: #000000;
    font-weight: bold;
    border-bottom-color: #F3F2E7;
    padding-top:4px;
 
}
.radiobuttonlist label:hover
{
    color: #CC3300;
    background: #D1CFC2;
}
 
.radiobuttoncontainer
{
    position:relative;
    z-index:1;
}
 
.radiobuttonbackground
{
    position:relative;
    z-index:0;
    border: solid 1px #AcA899; 
    padding: 10px; 
    background-color:#F3F2E7;
}
使用方法如下:
设置RadioButtonList的RepeatLayout"属性 为 "Flow"
如下:
<div class="radiobuttoncontainer">
    <asp:RadioButtonList ID="optTabs" runat="server" AutoPostBack="true" RepeatDirection="Horizontal"
        RepeatLayout="Flow" CssClass="radiobuttonlist">
        <asp:ListItem runat="server" Text="Locations" Value="LocationInformation_Manage"></asp:ListItem>
        <asp:ListItem Text="Address" Value="Address_Manage"></asp:ListItem>
        <asp:ListItem Text="Contacts" Value="Contacts_Manage"></asp:ListItem>
        <asp:ListItem Text="Comments" Value="CommentsList_Manage"></asp:ListItem>
        <asp:ListItem Text="Conveyances" Value="ConveyanceList_Manage"></asp:ListItem>
        <asp:ListItem Text="Permits" Value="PermitList_Manage"></asp:ListItem>
        <asp:ListItem Text="Invoices" Value="TransactionList_Manage"></asp:ListItem>
        <asp:ListItem Text="Analyze Invoices" Value="Annual_Invoice_Analysis_View"></asp:ListItem>
    </asp:RadioButtonList>
</div>
<div class="radiobuttonbackground">
    <asp:PlaceHolder ID="phEntity"  runat="server"></asp:PlaceHolder>
</div>
最后在Page_Load中添加如下代码:
optTabs.SelectedItem.Attributes.Add("class", "selectedradio")

一切OK,效果图如下:

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值