Search code examples
asp.netdatetimetelerikradtextbox

How to get current date in ASP.NET and telerik:RadTextBox


How can I see the current date in a .aspx file using telerik RadTextBox.

I tried this:

<telerik:RadTextBox ID="RadTextBox1" runat="server" Width="50%" ReadOnly="true" Text='<%# DateTime.Now.ToString("dd-MM-yyyy") %>' />

But I can't see anything.

Any idea? Thanks.


Solution

  • Do that on the server:

    private void Page_Load(object sender, System.EventArgs e)
    {
        RadTextBox1.Text = DateTime.Now.ToString("dd-MM-yyyy")
    }