On the form there is a certain <asp:Literal> in which the date is, how to set a specific format for this literal? I try this, it does not work:

 Literal2.Text = string.Format("{0:d}", Literal2); 

I register this line in the Page_Load () method.

  • And how do you assign the data? - Grundy

1 answer 1

if I understand you correctly, try this:

 Literal2.Text = string.Format("{0:d}", Convert.ToDateTime(Literal2.Text)); 
  • Everything turned out so simple) Thank you! - Denis