我需要asp.net日历控件的帮助 [英] i need help for asp.net calendar control
本文介绍了我需要asp.net日历控件的帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
亲爱的家伙。我必须限制访问或选择日历控制中任何前一天,月,年的日期,除了今天或明天之后的任何一天
受保护 无效 Calendar1_DayRender( object sender,System.Web.UI.WebControls.DayRenderEventArgs e)
{
if (e.Day.Date.ToShortDateString()< = DateTime.Now.ToShortDateString())
{
e.Cell.BackColor = ColorTranslator.FromHtml( # a9a9a9\" 跨度>);
e.Day.IsSelectable = false ;
}
}
这种方法只是改变背面颜色而不是禁用选择。我先提取了几天单独使用整数,因为如果也有一些错误。无论如何;它不起作用
protected void Calendar1_DayRender( object sender,DayRenderEventArgs e)
{
DateTime pastday = e.Day 。日期;
DateTime date = DateTime.Now;
int year = date.Year;
int month = date.Month;
int day = date.Day;
今日DateTime = new DateTime(年,月,日);
if (pastday.CompareTo(今天)< 0 )
{
e.Cell.BackColor = System.Drawing.Color.Gray;
e.Day.IsSelectable = false ;
}
}
这种方法不起作用
解决方案
不要使用此控件。
使用此功能! [ ^ ]
< span class =code-keyword> protected void Calendar1_DayRender( object sender,DayRenderEventArgs e )
{
if (e.Day.Date < DateTime.Now )
{
e.Cell.Text = e.Day.Date.Day.ToString();
e.Cell.BackColor = System.Drawing.Color.Gray;
e.Day.IsSelectable = false ;
}
}
参考此链接
ASP.NET AJAX日历扩展程序 - 提示和技巧[技巧-6 ] [ ^ ]
你可以找到很多定制,这对以后的使用也有好处。
问候......:笑:
Dear fellows.I have to restrict access or selection to the date of any previous Day,Month,Year in the Calendar Control except today's or any day(s) after tomorrow
protected void Calendar1_DayRender(object sender, System.Web.UI.WebControls.DayRenderEventArgs e)
{
if(e.Day.Date.ToShortDateString() <= DateTime.Now.ToShortDateString())
{
e.Cell.BackColor=ColorTranslator.FromHtml("#a9a9a9");
e.Day.IsSelectable=false;
}
}
this approach just change the back color and not disabling selection.I first extracted the days in integers separately because if also has some errors.Anyways;it doesn't work
protected void Calendar1_DayRender(object sender, DayRenderEventArgs e)
{
DateTime pastday = e.Day.Date;
DateTime date = DateTime.Now;
int year = date.Year;
int month = date.Month;
int day = date.Day;
DateTime today = new DateTime(year, month, day);
if (pastday.CompareTo(today) < 0)
{
e.Cell.BackColor = System.Drawing.Color.Gray;
e.Day.IsSelectable = false;
}
}
that approach didn't work as well
解决方案
Dont use this control.
Use this![^]
protected void Calendar1_DayRender(object sender, DayRenderEventArgs e) { if (e.Day.Date < DateTime.Now) { e.Cell.Text = e.Day.Date.Day.ToString(); e.Cell.BackColor = System.Drawing.Color.Gray; e.Day.IsSelectable = false; } }
Refer to this link
ASP.NET AJAX Calendar Extender–Tips and Tricks[Tip-6][^]
You can find lots of customizations,that would be beneficial for future use also.
Regards..:laugh:
这篇关于我需要asp.net日历控件的帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文