zoukankan      html  css  js  c++  java
  • 让用户更易看到选择了哪个选项

    用户反馈,单选项目,没能明显显示有选择中的是哪一个?原来是Insus.NET使用了一个RadioButtonList控件,显示了较多的项目,让用户去单选。默认的选中样式,引起用户反馈这个问题。钟对这个问题,Insus.NET稍做了一些程序修改,用户也接受了这个效果。可以看看:

     方法很简单,就是当选项被选中时,更改选中选项的前景色。

     <asp:RadioButtonList ID="RadioButtonListLaHao" runat="server" AutoPostBack="true" OnSelectedIndexChanged="RadioButtonListLaHao_SelectedIndexChanged" RepeatColumns="20" RepeatDirection="Horizontal" Width="100%">
                    </asp:RadioButtonList>

    上面Html代码有两个地方要注意的,一就是RadioButtonList的 AutoPostBack="true"属性,另一个就是OnSelectedIndexChanged="RadioButtonListLaHao_SelectedIndexChanged"的事件。

    变更选中选项的前景色,就是在这个事件进行,可参考。

    View Code
     protected void RadioButtonListLaHao_SelectedIndexChanged(object sender, EventArgs e)
        {
            var rbl = sender as RadioButtonList;
            HighliehgSelectedItem(rbl);
        }

        private void HighliehgSelectedItem(RadioButtonList rbl)
        {
            foreach (ListItem li in rbl.Items)
            {
                if (li.Selected)
                {
                    li.Attributes.Add("style""color: red;");
                }
            }
        }
  • 相关阅读:
    2017洛谷7月月赛总结
    poj3169 Layout
    poj3613Cow Relays
    洛谷P1418 选点问题
    poj3311Hie with the Pie
    poj1734Sightseeing trip
    poj3728The merchant
    洛谷P2420 让我们异或吧
    struts2.1笔记02:servlet简介
    struts2.1笔记01:MVC框架思想浅层理解
  • 原文地址:https://www.cnblogs.com/insus/p/2683216.html
Copyright © 2011-2022 走看看