User283571144 posted
Hi Naninani,
According to your question, I'm not sure if you want to show the date in textbox through label or if you want to change the date format in textbox.
If you want to show the date in textbox through label, you could refer to below codes:
<asp:TextBox ID="TextBox2" runat="server" TextMode="Date" AutoPostBack="true" OnTextChanged="TextBox2_TextChanged"></asp:TextBox><br />
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>/
<asp:Label ID="Label2" runat="server" Text="Label"></asp:Label>/
<asp:Label ID="Label3" runat="server" Text="Label"></asp:Label>
code behind
protected void TextBox2_TextChanged(object sender, EventArgs e)
{
Label1.Text = string.Format("{0:MM}", Convert.ToDateTime(TextBox2.Text));
Label2.Text = string.Format("{0:dd}", Convert.ToDateTime(TextBox2.Text));
Label3.Text = string.Format("{0:yy}", Convert.ToDateTime(TextBox2.Text));
}
Result:

If you want to change the date format in textbox, I recommend that you use the default format of textbox. By setting the format in the code behind, you can set any date format you want. You can refer to the following code.
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox><br />
<asp:Calendar ID="Calendar1" runat="server" OnSelectionChanged="Calendar1_SelectionChanged"></asp:Calendar>
Code-behind:
protected void Calendar1_SelectionChanged(object sender, EventArgs e)
{
TextBox1.Text = string.Format("{0:yyyy-MM-dd}", Calendar1.SelectedDate);
}
Result:

Best Regards,
Brando