DropDownList 控制日期控件显示格式
代码如下:
前台:
<script src="../js/My97DatePicker/WdatePicker.js" type="text/javascript"></script>
<script type="text/javascript"> $(document).ready(function () { $('#txtStartTime').bind('focus', function () { WdatePicker() }); $('#txtEndTime').bind('focus', function () { WdatePicker() }); });function GetDate() {
var obj = document.getElementById("ddlType");if (obj.value == "Month") {
$("#txtStartTime").unbind('focus').bind('focus', function () { WdatePicker({ dateFmt: 'yyyy-MM' }); }); $("#txtEndTime").unbind('focus').bind('focus', function () { WdatePicker({ dateFmt: 'yyyy-MM' }); }); } else { $("#txtStartTime").unbind('focus').bind('focus', function () { WdatePicker({ dateFmt: 'yyyy-MM-dd' }); }); $("#txtEndTime").unbind('focus').bind('focus', function () { WdatePicker({ dateFmt: 'yyyy-MM-dd' }); }); } } </script><input id="txtStartTime" readonly="readonly" style='width:100px' clientidmode="Static" type="text" runat="server"/>
<input id="txtEndTime" readonly="readonly" style='width:100px' clientidmode="Static" type="text" runat="server"/>后台:
ddlType.Attributes.Add("onchange ", "GetDate()");