Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
20
WebDateTime Editor
posted

Is there a way to show an editor for date and an editor for time?

I'm trying to bind a datetime field to an Infragistics Date Time editor and have a Windows Date and Time Properties interface.

Parents
No Data
Reply
  • 24497
    Suggested Answer
    posted

    Hi,

    WebDateTimeEditor supports any format related to date/time. You may use standard dotnet formats like "d", "t", "g", etc. or explicit formats like "HH:mm:ss", "dd/MM/yyyy", etc.

    However, WebDateTimeEditor is not able to provide "pure time" like TimeSpan, but only time-portion of date. Which means that end user will see only time-fields, but application will see all fields of DateTime. If date fields are missing, then fields of current date are used. So, if you need to get time portion, then you may substract Today date from date entered by user. Codes below show 3 editors: first shows to end user only date, second-time, third-date and time (all in current culture).

        <ig:WebDateTimeEditor ID="WebDateTimeEditor1" runat="server"></ig:WebDateTimeEditor>
        <ig:WebDateTimeEditor ID="WebDateTimeEditor2" runat="server" EditModeFormat="t"></ig:WebDateTimeEditor>
        <ig:WebDateTimeEditor ID="WebDateTimeEditor3" runat="server" EditModeFormat="g"></ig:WebDateTimeEditor>
        <asp:Label ID="Label1" runat="server"></asp:Label>
        <asp:Button ID="Button1" runat="server" Text="Button" />

    protected void Page_Load(object sender, EventArgs e)
    {
      this.Label1.Text = "<br />" + this.WebDateTimeEditor1.Date + "<br />" + this.WebDateTimeEditor2.Date + "<br />" + this.WebDateTimeEditor3.Date;
    }

Children