Dynamic RadDateTimePicker

7 posts, 0 answers
  1. Prava kafle
    Prava kafle avatar
    212 posts
    Member since:
    Apr 2010

    Posted 17 Feb 2012 Link to this post

    Hi,

    Dynamic RadDateTimePicker doesnot show DatePicker and Time Picker Buttons, It just displays a text box. How can I make these buttons visible on  initial page load. 

    These controls pop up only when I hover to the right of textbox.

    Thanks,
    Prava
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 20 Feb 2012 Link to this post

    Hello,

    I tried the same scenario in the version 2011.2.915.35 which worked as expected. Here is the sample code.
    C#:
    protected void Page_Load(object sender, EventArgs e)
    {
        RadDateTimePicker RadDateTimePicker1 = new RadDateTimePicker();
        RadDateTimePicker1.ID = "RadDatePicker1";
        form1.Controls.Add(RadDateTimePicker1);
    }

    -Shinu.
  3. Prava kafle
    Prava kafle avatar
    212 posts
    Member since:
    Apr 2010

    Posted 22 Feb 2012 Link to this post

    Hi Shinu,
    I have same code like yours but it does not show these controls on right side of Textbox. These controls display on hovering and when I set it, it doesnot persist the value on postback. On postback I get 1900.........
    Can you provide me a small sample where RadDateTimePicker is added dynamically and when date and time selected by user causes a post back to  update a label  with that  datetime.
  4. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 23 Feb 2012 Link to this post

    Hello,

    Here is the sample code that I tried.
    C#:
    RadDateTimePicker RadDateTimePicker1 = new RadDateTimePicker();
    Label Label1 = new Label();
     protected void Page_Load(object sender, EventArgs e)
      {
        RadDateTimePicker1.ID = "RadDateTimePicker1";
        RadDateTimePicker1.AutoPostBack = true;
        RadDateTimePicker1.SelectedDateChanged += new Telerik.Web.UI.Calendar.SelectedDateChangedEventHandler(RadDateTimePicker1_SelectedDateChanged);
        form1.Controls.Add(RadDateTimePicker1);
        Label1.ID = "Label1";
        form1.Controls.Add(Label1);
      }
    void RadDateTimePicker1_SelectedDateChanged(object sender, Telerik.Web.UI.Calendar.SelectedDateChangedEventArgs e)
      {
        string s = RadDateTimePicker1.SelectedDate.ToString();
        Label1.Text = s;
      }

    Thanks,
    Princy.
  5. Prava kafle
    Prava kafle avatar
    212 posts
    Member since:
    Apr 2010

    Posted 23 Feb 2012 Link to this post

    Hi Shinu,
    I forgot to add skin to RadDateandTimePicker Control and once I added it, Pop Up Button reappeared and my problem was solved.

    I have another question related to RadDatePicker Control. On ChildCreated  event, I would like to add a button control  called"SET CURRENT TIME", clicking this button will set RadDateTimePicker1.selecteddateandtime  = current dateandtime.

    I need this functionality because I am dynamically creating a RadDatepicker control in nested grid's edit item template.

    Thank you very much for your effort. 
    Prava
  6. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 23 Feb 2012 Link to this post

    Hello,

    Try the following code.
    C#:
    RadDateTimePicker RadDateTimePicker1 = new RadDateTimePicker();
    protected void Page_Load(object sender, EventArgs e)
     {
       RadDateTimePicker1.ID = "RadDateTimePicker1";
       RadDateTimePicker1.ChildrenCreated += new EventHandler(RadDateTimePicker1_ChildrenCreated);
       form1.Controls.Add(RadDateTimePicker1);
     }
    void RadDateTimePicker1_ChildrenCreated(object sender, EventArgs e)
     {
       Button Button1 = new Button();
       Button1.ID = "Button1";
       Button1.Text = "SET CURRENT TIME";
       form1.Controls.Add(Button1);
       Button1.Click += new EventHandler(Button1_Click);
     }
    void Button1_Click(object sender, EventArgs e)
     {
       RadDateTimePicker1.SelectedDate = System.DateTime.Now;
     }


    Thanks,
    Princy.
  7. Prava kafle
    Prava kafle avatar
    212 posts
    Member since:
    Apr 2010

    Posted 24 Feb 2012 Link to this post

    Hi,

    It did the trick, thanks Princy!

    Regards,
    Prava
Back to Top