TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Jes Sie
743
1.2k
280.9k
Restrict Selecting Date from Calendar Control
Feb 26 2017 11:38 PM
I have 2 textboxes, the first textbox is a date from the database and the second textbox is asp:calendar. Now, this is what I want to achieve: Textbox2 cannot select a date older that what is in textbox1. Below is my code but it is not working.
html and c# code:
<
ajaxToolkit:CalendarExtender
ID
=
"calFirst"
runat
=
"server"
TargetControlID
=
"TextBox1"
CssClass
=
"MyCalendar"
Format
=
"MMMM d, yyyy"
/>
<
asp:TextBox
ID
=
"TextBox1"
runat
=
"server"
>
asp:TextBox
>
<
br
>
<
asp:TextBox
ID
=
"TextBox4"
runat
=
"server"
>
asp:TextBox
>
<
asp:ImageButton
ID
=
"ImageButton1"
runat
=
"server"
Height
=
"17px"
ImageUrl
=
"~/img/calendar.png"
OnClick
=
"ImageButton1_Click"
Width
=
"21px"
/>
<
asp:Calendar
ID
=
"Calendar1"
runat
=
"server"
OnSelectionChanged
=
"Calendar1_SelectionChanged"
OnDayRender
=
"Calendar1_DayRender"
Visible
=
"False"
>
asp:Calendar
>
protected
void
Calendar1_SelectionChanged(
object
sender, EventArgs e)
{
TextBox4.Text = Calendar1.SelectedDate.ToShortDateString();
Calendar1.Visible =
false
;
}
protected
void
Calendar1_DayRender(
object
sender, DayRenderEventArgs e)
{
DateTime date = Convert.ToDateTime(TextBox1.Text);
if
(e.Day.Date > date)
{
e.Cell.Enabled =
false
;
e.Day.IsSelectable =
false
;
}
}
protected
void
ImageButton1_Click(
object
sender, ImageClickEventArgs e)
{
Calendar1.Visible =
true
;
}
Reply
Answers (
6
)
How to create SPA with Asp.net core?
How to send mail by using MVC 5