Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable previous date and time in text-box mode "date" in ASP.NET

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;
    }
}
like image 604
KKDev Avatar asked Oct 19 '25 15:10

KKDev


1 Answers

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");
like image 73
KKDev Avatar answered Oct 21 '25 04:10

KKDev



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!