This is a migrated thread and some comments may be shown as answers.

Javascript error 'this.Slots.Month' is null or not an object

6 Answers 95 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
Edwin
Top achievements
Rank 1
Edwin asked on 12 Jan 2009, 03:20 PM
Hi
I have a composite control which contains a DateTimePicker control and other child controls.  The composite control is in a visual studio solution which has a class project (for generating the dll of my composit controls) and a web site (for testing the dll).  I can run the composite control in the testing web site.  However, when I include the dll in my other projects, I got the javascript error 

'this.Slots.Month' is null or not an object

when a date or time is selected in the pop up calendar.  In debug mode, it stopped in

parseDate:function(_fe,_ff){
try{
var _100=new Telerik.Web.UI.DateParsing.DateTimeLexer(this.get_dateFormatInfo());
var _101=_100.GetTokens(_fe);
var _102=new Telerik.Web.UI.DateParsing.DateTimeParser(this.get_dateFormatInfo().TimeInputOnly);
var _103=_102.Parse(_101);
_ff=this._getParsingBaseDate(_ff);
var date=_103.Evaluate(_ff,this.get_dateFormatInfo());
return date;
<====== stopped here
catch(parseError){
if(parseError.isDateParseException){
return null;
}else{
throw parseError;
}
}
}

I have no clue about what caused the error.  Your help is much appreciated.

Edwin

6 Answers, 1 is accepted

Sort by
0
Edwin
Top achievements
Rank 1
answered on 12 Jan 2009, 03:54 PM
After some further testing, I found that the error also occurred when using ordinary DataTimePicker control in my projcet.  Therefore I can exclude the possibility of bugs in my composite control.  Then what can cause such error?

Edwin
0
Edwin
Top achievements
Rank 1
answered on 13 Jan 2009, 03:32 AM
I know what caused the error but don't know how to solve.

My pages extend from customized Page class where the following code is executed in the InitializeCulture() event.

 

CultureInfo cultureInfo = (CultureInfo)Thread.CurrentThread.CurrentCulture.Clone();

 

cultureInfo.DateTimeFormat.ShortDatePattern = "d MMM yy";  //no error if commented out this line

 

try

 

{

 

Thread.CurrentThread.CurrentCulture = cultureInfo;

 

}

 

catch

 

{

}

Do you know how to solve this?  Note:  It caused no error for DatePicker.  Just not working for DateTimePicker!

0
Dimo
Telerik team
answered on 14 Jan 2009, 09:32 AM
Hello Edwin,

Please avoid opening two forum threads for the same problem.

In your custom DateTimeFormat you are using a DateSeparator (space), which is different from the default one (slash). You should set the DateSeparator explicitly:

cultureInfo.DateTimeFormat.ShortDatePattern = "dd MMM yy";
cultureInfo.DateTimeFormat.DateSeparator = " ";


Kind regards,
Dimo
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Ayaz Anwar
Top achievements
Rank 1
answered on 10 Aug 2009, 01:55 PM
I am using Telerik Calendar control and setting Current Culture on ASP.NET page using following code

System.Threading.Thread.CurrentThread.CurrentCulture = new GCAACulture(System.Threading.Thread.CurrentThread.CurrentCulture.Name);
System.Threading.Thread.CurrentThread.CurrentCulture.DateTimeFormat.DateSeparator = " ";

public class GCAACulture : CultureInfo
    {
       public GCAACulture(string cultureName) : base(cultureName)
       {
          this.DateTimeFormat = new System.Globalization.DateTimeFormatInfo();
          this.DateTimeFormat.ShortDatePattern = "dddd, dd MMMM yyyy";
          this.DateTimeFormat.LongDatePattern = "dddd, dd MMMM yyyy";
       }
    }


But whenever I select date using date picker popup always current day is selected. When I debug the telerik javascript code then I found that code fails to parse of day of selected dated and as result it selected current (Today) date as an alternate. The day part of selected date returning null value.

While debugging I  found that something is wrong in following method.

parseDate:function(_fe,_ff){
try{
var _100=new Telerik.Web.UI.DateParsing.DateTimeLexer(this.get_dateFormatInfo());
var _101=_100.GetTokens(_fe);
var _102=new Telerik.Web.UI.DateParsing.DateTimeParser(this.get_dateFormatInfo().TimeInputOnly);
var _103=_102.Parse(_101);
_ff=this._getParsingBaseDate(_ff);
var date=_103.Evaluate(_ff,this.get_dateFormatInfo());
return date;
}





Please help me from where I am making mistake.

Regards
Ayaz Anwar
Software Engineer




0
Dimo
Telerik team
answered on 13 Aug 2009, 06:06 AM
Hello Ayaz,

The DateSeparator of the culture must match the DateSeparator of the RadDatePicker control, especially when using a custom DateTimeFormat. In addition, you can't use a space as a literal in the custom DateTimeFormat, if it is used as a separator.

In other words, this will work as expected:

this.DateTimeFormat = new System.Globalization.DateTimeFormatInfo();
this.DateTimeFormat.ShortDatePattern = "dddd,dd MMMM yyyy";
this.DateTimeFormat.LongDatePattern = "dddd,dd MMMM yyyy";
this.DateTimeFormat.DateSeparator = " ";


You will not need this line:

System.Threading.Thread.CurrentThread.CurrentCulture.DateTimeFormat.DateSeparator = " ";


Kind regards,
Dimo
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Ayaz Anwar
Top achievements
Rank 1
answered on 13 Aug 2009, 10:46 AM
Hi Dimo,

Thankx for your prompt repsonse, It worked. It solved my problem.

Regards
Ayaz Anwar
Software Engineer
Tags
Calendar
Asked by
Edwin
Top achievements
Rank 1
Answers by
Edwin
Top achievements
Rank 1
Dimo
Telerik team
Ayaz Anwar
Top achievements
Rank 1
Share this question
or