1. Referencing my97 js and CSS
2. Foreground code
<div class= "FormItem" >
<label>
Application Time </label>
<div class= "Formitemelement" >
<input type= "text" id= "txt_applydate" style= "width:200px; Cursor:pointer; "readonly=" readonly "class=" txt wdate "value=" <%=_date%> "
Onclick= "SetTime ();" required= "true"/>
</div>
</div>
3.js Code
<script language= "javascript" type= "Text/javascript" >
Set the time
function SetTime () {
Wdatepicker ({mindate: ' <%=_mindate%> ', maxdate: ' <%=_maxdate%> '})
}
</script>
4. Background code
public string _mindate = "";
public string _maxdate = "";
protected void Page_Load (object sender, EventArgs e)
{
if (DateTime.Now.DayOfWeek = = System.DayOfWeek.Monday)//Judge whether Monday
{
_maxdate = DateTime.Now.ToString ("Yyyy-mm-dd");
_mindate = DateTime.Now.AddDays (-3). ToString ("Yyyy-mm-dd");
}
else if (DateTime.Now.DayOfWeek = = System.DayOfWeek.Saturday)//Judging whether Saturday
{
_maxdate = DateTime.Now.ToString ("Yyyy-mm-dd");
_mindate = DateTime.Now.AddDays (-1). ToString ("Yyyy-mm-dd");
}
else if (DateTime.Now.DayOfWeek = = System.DayOfWeek.Sunday)//judge whether Sunday
{
_maxdate = DateTime.Now.ToString ("Yyyy-mm-dd");
_mindate = DateTime.Now.AddDays (-2). ToString ("Yyyy-mm-dd");
}
Else
{
_maxdate = DateTime.Now.ToString ("Yyyy-mm-dd");
_mindate = DateTime.Now.AddDays (-2). ToString ("Yyyy-mm-dd");
}
}
My97 set the date for nearly 3 days