rad datetime picker

5 posts, 0 answers
  1. Tiaan
    Tiaan avatar
    12 posts
    Member since:
    Mar 2014

    Posted 26 Mar 2014 Link to this post

    Good day

    I have a rad datetime picker on a asp website

    I have to create the control dynamically.
    I added an event handler to the control, but  the event is not firing at all.

    Also i added an ID to the control which is not showing when i try and find that control trough firefox debugger.

     RadDateTimePicker dt = new RadDateTimePicker();
                        dt.SelectedDateChanged += new Telerik.Web.UI.Calendar.SelectedDateChangedEventHandler(dt_SelectedDateChanged);
                        dt.ID = "datetimepicker007";
                        Cell.Controls.Add(dt);


       void dt_SelectedDateChanged(object sender, Telerik.Web.UI.Calendar.SelectedDateChangedEventArgs e)
            {
              //  throw new NotImplementedException();
                Response.Redirect("www.google.com");
            }

  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 26 Mar 2014 in reply to Tiaan Link to this post

    Hi Tiaan,

    In order to fire the SelectedDateChanged event of RadDateTimePicker please try to set the AutoPostBackControl property of RadDateTiemPicker. This property indicates whether a postback to the server will occur when the user changes the time or date selection. This is useful when you would like to trigger form submit on date/time selection individually or for both controls. Please add the following C# code which works fine at my end.

    C#:
    dt.AutoPostBackControl = Telerik.Web.UI.Calendar.AutoPostBackControl.Calendar;

    Thanks,
    Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Tiaan
    Tiaan avatar
    12 posts
    Member since:
    Mar 2014

    Posted 27 Mar 2014 Link to this post

    Good day

    The eventhandler control worked.
    But now i have a much bigger problem . My page is dynamically created in page init, this occurs before the actual method for selecteddatechanged.
    So when it enters init, it created the picker again, and when it comes to the datechanged method, its blank.
  5. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 27 Mar 2014 in reply to Tiaan Link to this post

    Hi Tiaan,

    Please have a look into the sample code snippet which works fine at my end.

    C#:
    protected void Page_Init(object sender, EventArgs e)
    {
        RadDateTimePicker dt = new RadDateTimePicker();
        dt.ID = "DatePicker1";
        dt.AutoPostBackControl = Telerik.Web.UI.Calendar.AutoPostBackControl.Calendar;
        dt.SelectedDateChanged += new Telerik.Web.UI.Calendar.SelectedDateChangedEventHandler(dt_SelectedDateChanged);
        form1.Controls.Add(dt);
    }
    void dt_SelectedDateChanged(object sender, Telerik.Web.UI.Calendar.SelectedDateChangedEventArgs e)
    {
       //your code
    }

    Let me know if you have any concern.
    Thanks,
    Shinu.
  6. Tiaan
    Tiaan avatar
    12 posts
    Member since:
    Mar 2014

    Posted 28 Mar 2014 Link to this post

    Hi

    I found a fix for my bug. Unfortunately your code wouldn't work as i need to dynamically create the picker in code under a few if statements that can only be seen in that scope. I initially thought that the creation method needed to be under page init, The init method clears all data, But when i moved it to page load, the data was held.

    Something interesting to read up on :-)

    Thank you for your input
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017