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
405
Two DateTimeEditorFor take the same value
posted

Hi I have two DateTimeEditorFor editors for an Meeting StartTime and a EndTime (see Screenshot). Now if I inser 12:30 as Start Time and 15:15 as End Time, in the debugger both fields have the same value (see Screenshot). Is this a Bug? Or have I made any mistakes?

Screenshots double times.zip
  • 2895
    posted

    Hello Stanislas,

    Thank you for using our community.

    I have investigated your case and manages to pass the editors values when submitting and the values are accurate. Here is how I accomplished that:

    @(Html.Infragistics()

        .DateTimeEditorFor(m => m.StartDate)

        .ID("dateInfo")

        .Width(100)

        .DateDisplayFormat("time")

        .NullText("Enter Date")

        .DateInputFormat("hh:mm:ss")

        .Render()

    )  

     

    @(Html.Infragistics()

        .DateTimeEditorFor(m => m.EndDate)

        .ID("dateTermino")

        .Width(100)

        .DateDisplayFormat("time")

        .NullText("Enter Date")

        .DateInputFormat("hh:mm:ss")

        .Render()

    )

    <input id="btn" type="button" title="Submit" value="Submit"/>

     

        $("#btn").click(function submitHandler() {

            var startValue = $("#dateTermino").igEditor("option", "value");

            var startTime = startValue.getHours() + ":" + startValue.getMinutes() + ":" + startValue.getSeconds();

     

            var endValue = $("#dateInfo").igEditor("option", "value");

            var endTime = endValue.getHours() + ":" + endValue.getMinutes() + ":" + endValue.getSeconds();

     

            $.ajax({

                type: "POST",

                data: { newEndTime: endTime, newStartTime: startTime },

                url:"@Url.Action("SaveTime")",

                success:function successHandler() {

                    aler("time");

                }

            })

        });

     

    public ActionResult SaveTime(DateTime? newEndTime, DateTime? newStartTime)

    {  …

    }

    Please take a look at the code I provided you and let me know how it works for you.