Home > Software engineering >  Want to Fetch date from sql to textbox textmode=date
Want to Fetch date from sql to textbox textmode=date

Time:11-18

I tried to fetch a date from textbox where textbox mode is date.

<asp:TextBox ID="txtDate"    required="required" TextMode="Date" runat="server"  ></asp:TextBox>


txtDate.Text = Convert.ToDateTime(dt.Rows[0]["Date"]).ToString("dd-MM-yyyy");

but still it showing dd-mm-yyyyy in frontend

want to fetch value to textbox

CodePudding user response:

This is a browser / HTML 5 specification issue, not webforms. It only takes a RFC3339 formatted date (YYYY-MM-DD).

So use

txtDate.Text = DateTime.Now.ToString("yyyy-MM-dd");
  • Related