I have Calendar like this one:
View
<td> <asp:Calendar ID="Calendar1" runat="server" OnSelectionChanged="DateChange"> </asp:Calendar> <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox> </td>
.Cs file
protected void Page_Load(object sender, EventArgs e) { TextBox2.Text = DateTime.Today.ToShortDateString()+'.'; } protected void DateChange(object sender, EventArgs e) { TextBox2.Text = Calendar1.SelectedDate.ToShortDateString() + '.'; }
It display date as "MM/dd/yyyy"
, but I want to display it as "dd/MM/yyyy"
, I try it changing DateTime.Today.ToShortDateString()+'.';
to DateTime.Today.ToShortDateString("dd/MM/yyyy");
but I get
Error 3 No overload for method 'ToShortDateString' takes 1 arguments
What can I do to solve this?
ToShortDateString() Method in C# The DateTime. ToShortDateString() method in C# is used to convert the value of the current DateTime object to its equivalent short date string representation.
ParseExact: This method can be used when you want to get exact format of date. There are different arguments which you need to pass while converting to a format. Value: It is string representation of date and time.
ToShortDateString
does not have an overload which takes any parameter.
If your ToShortDateString()
returns MM/dd/yyyy
format, that means your CurrentCulture
has this format in it's ShortDatePattern
property.
You can always use custom formatting for that like with proper culture like;
TextBox2.Text = DateTime.Today.ToString("dd/MM/yyyy", CultureInfo.InvariantCulture);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With