Home Search Member List Faq Register Login  
UltimateCalendar
Re: Setting date in DatePicker via Javascript

Thread Starter: Gaaahhhh   Started: 12-03-2007 6:07 PM   Replies: 8
 Karamasoft Support Forums » General Discussions » UltimateCalendar » Re: Setting date in DatePicker via Javascript
 Printable Version    « Previous Thread   Next Thread »
  03 Dec 2007, 6:07 PM
Gaaahhhh is not online. Last active: 12/6/2007 9:39:12 PM Gaaahhhh

Top 10 Posts
Joined on 12-03-2007
Posts 14
Setting date in DatePicker via Javascript
Ok, maybe im missing something.. (probably)

How do I set the date and have it formatted by the date picker in Javascript.

Your examples page does not show this.

http://www.karamasoft.com/Samples.aspx?component=UltimateCalendar

Any ideas?

  
  04 Dec 2007, 11:10 AM
Karamasoft is not online. Last active: 5/8/2018 10:36:45 AM Karamasoft

Top 10 Posts
Joined on 09-05-2004
Posts 6,820
Re: Setting date in DatePicker via Javascript
You can set the initial text of the date picker textbox as follows:

UltimateDatePicker1.DatePickerTextBox.Text = UltimateCalendar1.SelectedDate.ToShortDateString()

You can also set DateFormat attribute of UltimateDatePicker to a value described in the Date Format section at http://www.karamasoft.com/UltimateCalendar/ClientAPI.htm


  
  04 Dec 2007, 1:58 PM
Gaaahhhh is not online. Last active: 12/6/2007 9:39:12 PM Gaaahhhh

Top 10 Posts
Joined on 12-03-2007
Posts 14
Re: Setting date in DatePicker via Javascript
Thats server-side (C#)  code - i want to set it in Javascript - and have the formatting set in "DateFormat" property respected.

Also, you talk about setting it "initially" - i need to be able to set it based on other events that are happening on the page after it has been loaded (ie. a check box is set etc) and need to be able to set it at that point, not initially.

Is there a way to do this?

  
  04 Dec 2007, 5:44 PM
Karamasoft is not online. Last active: 5/8/2018 10:36:45 AM Karamasoft

Top 10 Posts
Joined on 09-05-2004
Posts 6,820
Re: Setting date in DatePicker via Javascript

ClientAPI documentation we menitoned in our previous post has some of the methods you need.

Use _OnLoad function template to handle events after the calendar is loaded during page load on the client-side as follows:

function UltimateCalendar1_OnLoad() {
   /* UltimateCalendar1 is fully loaded on the client-side at this point */
}

Use GetDatePickerInputElem method to get the date picker textbox on the client-side as follows:

var datePickerInputElem = UltimateCalendars['UltimateCalendar1'].GetDatePickerInputElem();

Use SetDateFormat method to a given date format as follows:

UltimateCalendars['UltimateCalendar1'].SetDateFormat('MM/dd/yy');

Use GetSelectedDate and SetSelectedDate methods to get and set the selected date as follows:

var selectedDate = UltimateCalendars['UltimateCalendar1'].GetSelectedDate();
UltimateCalendars['UltimateCalendar1'].SetSelectedDate(new Date(2000, 0, 1));

If you let us know about your specific needs, we can help you better.


  
  04 Dec 2007, 5:57 PM
Gaaahhhh is not online. Last active: 12/6/2007 9:39:12 PM Gaaahhhh

Top 10 Posts
Joined on 12-03-2007
Posts 14
Re: Setting date in DatePicker via Javascript

Using the SetSelectedDate() method in javascript does not appear to actually set and display the date in the date picker. Here is my sample code - what am i missing?

When I run this, i get no javascript errors and the uc1 variable get set correctly to the UltimateCalendar object, but the SetSelectedDate method does not set and display the DatePicker text.

Here is the relevant HTML:

<script language="javascript" type="text/javascript">

<!--

var dpId = '<%=UltimateCalendar1.ClientID%>';

function ToggleDate()

{

var uc1 = UltimateCalendars[dpId];

uc1.SetSelectedDate(new Date(2000,0,1));

}

//-->

</script>


 

<cc1:UltimateDatePicker ID="UltimateDatePicker1" runat="server" UltimateCalendarID="UltimateCalendar1" DateFormat="ddd, dd MMM" ShowCalendarOnTextClick="true"/>

<cc1:UltimateCalendar ID="UltimateCalendar1" runat="server"/>

...

<a href=ToggleDate();">Set Date</a>



  
  04 Dec 2007, 6:01 PM
Gaaahhhh is not online. Last active: 12/6/2007 9:39:12 PM Gaaahhhh

Top 10 Posts
Joined on 12-03-2007
Posts 14
Re: Setting date in DatePicker via Javascript
gaaah that screwed with the javascript... last line should read

<a href='BLOCKED SCRIPTToggleDate();'>Set Date</a>


  
  04 Dec 2007, 6:06 PM
Gaaahhhh is not online. Last active: 12/6/2007 9:39:12 PM Gaaahhhh

Top 10 Posts
Joined on 12-03-2007
Posts 14
Re: Setting date in DatePicker via Javascript
oh i give up. Stick out tongue

im trying to put j a v a s c r i p t : ToggleDate(); (minus the spaces)

why doesnt the preview show the blocked script???

anyway, you get the idea...

  
  04 Dec 2007, 6:43 PM
Karamasoft is not online. Last active: 5/8/2018 10:36:45 AM Karamasoft

Top 10 Posts
Joined on 09-05-2004
Posts 6,820
Re: Setting date in DatePicker via Javascript
There is a problem with SetSelectedDate method. We will fix this issue and let you know when it is ready to download. Once we fix it, you can use the following JavaScript code:

<script type="text/javascript">
var
dpId = '<%=UltimateCalendar1.ClientID%>';
var dpTextBoxID = '<%=UltimateDatePicker1.DatePickerTextBox.ClientID%>';

function ToggleDate() {
   var uc1 = UltimateCalendars[dpId];
   uc1.SetSelectedDate(
new Date(2000,0,1));
   document.getElementById(dpTextBoxID).value = uc1.FormatDate(uc1.GetSelectedDate());
}
</script>

In the meantime, you can use SetSelectedDates method instead of SetSelectedDate as follows:

uc1.SetSelectedDates(new Array(new Date(2000,0,1)));


  
  04 Dec 2007, 8:14 PM
Gaaahhhh is not online. Last active: 12/6/2007 9:39:12 PM Gaaahhhh

Top 10 Posts
Joined on 12-03-2007
Posts 14
Re: Setting date in DatePicker via Javascript

Awesome. Thanks for your speedy response.


  
 Page 1 of 1 (9 items)
Karamasoft Support Forums » General Discussions » UltimateCalendar » Re: Setting date in DatePicker via Javascript

You can add attachments
You can post new topics
You can reply to topics
You can delete your posts
You can edit your posts
You can create polls
You can vote in polls
Forum statistics are enabled
Forum is unmoderated

© 2002-2020 Karamasoft LLC. All rights reserved.