日期:2014-05-17  浏览次数:20474 次

关于页面显示的简单问题,在线等
asp.net,语言用的c#
现在页面上有一组radiobutton,其中一项需要根据时间来确定是否显示,当前月份小于3或者大于9的时候显示,其他时间不显示。这个问题如何解决啊?


------解决方案--------------------
要么动态生成,要么用javascript根据条件去隐藏控件
------解决方案--------------------
HTML code


<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script language="javascript">
        function controlRdo() {
            var myRadios = document.getElementsByName("RadioButton1");
            var theDate = new Date();
            var s = "";
            s = (theDate.getMonth() + 1);
            if (s >= 9 || s <= 3) {
                for (var i = 0; i < myRadios.length; i++) {
                    myRadios[i].style.display = "none";
                    myRadios[i].nextSibling.style.display = "none";
                }
                
            }
        }
    </script>
</head>
<body onload="controlRdo();">
    <form id="form1" runat="server">
    <div>
        <asp:RadioButton ID="RadioButton1" runat="server"  Text="男" />
    </div>
    </form>
</body>
</html>

------解决方案--------------------
楼上说的很对,结果是一样的,用什么方法不行呢
Page_Load
DateTime m = DateTime.Now;
int mon = m.Month;
if (mon > 9 || mon < 3)
{
RdoType6.Visible = false;
}
------解决方案--------------------
JS判断的是本地时间
建议在服务端用C#代码控制。