Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Problem with SPDatePickerControl (WSS 3.0) (C#)

14 views
Skip to first unread message

r...@mailme.dk

unread,
May 27, 2008, 9:14:11 AM5/27/08
to
Hey
I have a WEB part with the following:


private SPDatePickerControl _myDateField;

protected override void CreateChildControls()
{
base.CreateChildControls();
_myDateField = new SPDatePickerControl();
_myDateField.Calendar = SPCalendarType.Gregorian;
_myDateField.SelectedDate =
DateTime.Today.ToLongDateString();
this.Controls.Add(_myDateField);
}

The Datepicker controls shows up all fine but as soon as I start to
invorke the control by clicking "Next Month" or "Previous Month"
nothing happens except I recieve an javascript error (Object Expected
Line 1 - Char 1) ..

Why ??


David Sterling

unread,
Aug 7, 2008, 2:19:01 PM8/7/08
to
It's missing the Javascript file necessary to render - simply add:

writer.Write("<script type=\"text/javascript\"
src=\"/_layouts/datepicker.js\"></script>");

ALSO: you must include the Style sheet:

writer.Write("<link rel=\"stylesheet\" type=\"text/css\"
href=\"/_layouts/1033/styles/datepicker.css\" />");


--
David M. Sterling
Author MOSS 2007 The Complete Reference
www.sterling-consulting.com

david_s...@sterling-consulting.com

unread,
Jun 27, 2017, 10:33:33 AM6/27/17
to
Be aware - in SP13, 15 has to be added to the path (SP16 = 16):

writer.Write("<script type=\"text/javascript\"
src=\"/_layouts/15/datepicker.js\"></script>");

ALSO: you must include the Style sheet:

writer.Write("<link rel=\"stylesheet\" type=\"text/css\"
href=\"/_layouts/15/1033/styles/datepicker.css\" />");
0 new messages