Reputation: 160
I want to disable previous date
and time
in textbox (TextMode DateTime
)
I#ve tried this in calendar control and that was successful but my requirement is to do it only in textbox.
protected void Calendar1_DayRender(object sender, DayRenderEventArgs e){
if (e.Day.Date < DateTime.Now.Date){
e.Day.IsSelectable = false;
e.Cell.ForeColor = System.Drawing.Color.Gray;
}
}
Upvotes: 3
Views: 8456
Reputation: 160
I have tried many way to resolve this problem but finally i get this solution.
Design
<asp:TextBox ID="txtstartdate" runat="server" TextMode="Date"></asp:TextBox>
Code
txtstartdate.Attributes["min"] = DateTime.Now.ToString("yyyy-MM-dd");
Upvotes: 6