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

this.datetimeformat is undefined error in firefox

21 Answers 311 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
bkj
Top achievements
Rank 1
bkj asked on 07 Oct 2008, 02:57 PM
I'm getting this error using the RadControls for ASP.NET AJAX in Firefox 3. (As reported by Firebug)

It occurs on the this.dateTimeFormat.AbbreviatedMonthNames expression in the following code.

function Sys$CultureInfo$_getAbbrMonthIndex(value) {
    if (!this._upperAbbrMonths) {
       this._upperAbbrMonths =                     this._toUpperArray(this.dateTimeFormat.AbbreviatedMonthNames);
     return Array.indexOf(this._upperMonths, this._toUpper(value));
}

This has been a known bug in ASP.NET AJAX -- and apparently still is in Firefox.

Does anyone know a solution or workaround?

Thanks,

Randy

21 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 09 Oct 2008, 08:00 AM
Hi bkj,

I cannot reproduce this problem in our online demos. I have tested with FireFox 3.0.3 and FireBug 1.121.

Regards,
Albert
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Brian
Top achievements
Rank 2
answered on 13 Nov 2008, 09:57 PM
Albert, it only happens when scripts are in "Debug" mode. Release is fine, can you try to duplicate in debug mode -- if you haven't already?
0
Val
Top achievements
Rank 1
answered on 24 Jan 2009, 08:12 PM
Any solution to this problem?
0
Veselin Vasilev
Telerik team
answered on 26 Jan 2009, 06:48 AM
Hello all,

This seems to be a known bug in MS Ajax. Please try the workaround submitted here.

Best wishes,
Veselin Vasilev
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Val
Top achievements
Rank 1
answered on 26 Jan 2009, 02:25 PM
I applied the workaround and it worked. I still have a few issues with a page but it proved to be a server side error. By the way, what is the best practice in catching an exception in the browser when it was thrown on a AJAX callback? Without Ajax you get yellow screen of death, with Ajax nothing, best case I get a javascript issue trapped by Firebug.
0
Val
Top achievements
Rank 1
answered on 26 Jan 2009, 02:50 PM
I got it.

http://www.telerik.com/help/aspnet-ajax/ajxerrorhandling.html
0
cmarsh
Top achievements
Rank 1
Iron
answered on 30 Jan 2009, 09:21 PM

We are having the problem as well. I put the following in the Page_Load method of the master page and still get the same error (also tried actual page's Page_Load with same result).

 

 

 

ClientScriptManager cs = Page.ClientScript;

 

 

if (!cs.IsStartupScriptRegistered(this.GetType(), "AjaxBugFix"))

{

 

string str = "Sys.CultureInfo.prototype._getAbbrMonthIndex = function(value) { ";

str +=

"if (!this._upperAbbrMonths) { ";

 

 

str +=

"this._upperAbbrMonths = this._toUpperArray(this.dateTimeFormat.AbbreviatedMonthNames); } ";

 

 

str +=

"return Array.indexOf(this._upperAbbrMonths, this._toUpper(value)); };";

 

 

cs.RegisterStartupScript(

this.GetType(), "AjaxBugFix", str, true);

 

 

}

 

0
Veselin Vasilev
Telerik team
answered on 02 Feb 2009, 01:48 PM
Hello cmarsh,

If you use RadTreeView for ASP.NET Ajax you need to use the RegisterStartupScript static method of the ScriptManager class.

Regards,
Veselin Vasilev
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
cmarsh
Top achievements
Rank 1
Iron
answered on 02 Feb 2009, 06:11 PM
I added the following to both the master page and the individual page and still get the same error.

 

string str = "Sys.CultureInfo.prototype._getAbbrMonthIndex = function(value) { ";

 

str +=

"if (!this._upperAbbrMonths) { ";

 

str +=

"this._upperAbbrMonths = this._toUpperArray(this.dateTimeFormat.AbbreviatedMonthNames); } ";

 

str +=

"return Array.indexOf(this._upperAbbrMonths, this._toUpper(value)); };";

 

 

ScriptManager.RegisterStartupScript(this, this.GetType(), "AjaxBugFix", str, true);

 

0
Veselin Vasilev
Telerik team
answered on 05 Feb 2009, 01:57 PM
Hi cmarsh,

I am out of ideas why it is not working. Can you please open a support ticket and attach there a sample running project demonstrating the issue.

Thanks

Greetings,
Veselin Vasilev
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Mark
Top achievements
Rank 1
answered on 10 Mar 2009, 04:55 PM
I'm having the same problem.  This code in the MasterPage does not appear to work:

Firefox v3.0.7
Firebug v1.3.3

 

Dim Str = "Sys.CultureInfo.prototype._getAbbrMonthIndex = function(value) { "

 

Str +=

"if (!this._upperAbbrMonths) { "

 

Str +=

"this._upperAbbrMonths = this._toUpperArray(this.dateTimeFormat.AbbreviatedMonthNames); } "

 

Str +=

"return Array.indexOf(this._upperAbbrMonths, this._toUpper(value)); };"

 

ScriptManager.RegisterStartupScript(

Me, Me.GetType(), "AjaxBugFix", Str, True)

 

0
Nik
Top achievements
Rank 1
answered on 22 Apr 2009, 11:05 AM
For those who are still facing this problem with MS AJAX 3.5, there is a bug in AjaxControlToolkit.Common.Common.js file. If you scroll down to the very bottom of the file you will see this

f (Sys.CultureInfo.prototype._getAbbrMonthIndex) {
    try {
             Sys.CultureInfo.prototype._getAbbrMonthIndex('');
        del('');
    } catch (ex) {
.....

Replace the try block by

 try {
        var del = Function.createDelegate(Sys.CultureInfo.CurrentCulture != null ? Sys.CultureInfo.CurrentCulture : Sys.CultureInfo.InvariantCulture, Sys.CultureInfo.prototype._getAbbrMonthIndex);
        del('');
    } catch (ex) {
......


keeping the catch block and everything else the same. This should fix this error up. Leave me a message on www.matrixconnects.com if you need to understand the fix!

PS: Yeah I am promoting my site, I am shameless!
0
Ricardo Pinto
Top achievements
Rank 1
answered on 06 May 2009, 01:43 PM
Hello!

I'm having the same problem here in a RadWindow.

In this window I dynamically fill a table with multiple columns / rows and some of the cells with a LinkButton.
During this process, I get the following error detected in firebug:

unterminated string literal
'return false;\n

I understand that the bug is in the MS AJAX framework, but how can I fix it?
Where can I find and edit AjaxControlToolkit.Common.Common.js file?

Thanks for your help!

Ricardo.



0
Nik
Top achievements
Rank 1
answered on 06 May 2009, 01:47 PM
Hi Ricardo

I don't think your problem is related to MS AJAX datetime literal issue. Can you post more details?

0
Ricardo Pinto
Top achievements
Rank 1
answered on 06 May 2009, 02:31 PM

Thanks Nik!

My code structure is the following
Aspx1 - grid; on row button click, opens RadWindow
Aspx2 - inside RadWindow, includes an ascx1 with all the dynamic generation logic
Aspx3 -  My main goal is to open another RadWindow with aspx3, when I click in each one of the LinkButtons I dynamically generate in ascx1 (inside aspx2).

The generation is done with the following code:

TC = New HtmlTableCell
img = 
New LinkButton 
img.ID = "M" & dtInicio.Year.ToString & dtInicio.Month.ToString & i & j 
img.Text = SelectedAcronyms(j) 
img.Width = Unit.Pixel(16) 
img.ToolTip = SelectedTooltip(j) 
If SelectedReturnID.Count > 0 Then 
   img.CommandArgument = SelectedReturnID(j) 
   AddHandler img.Click, AddressOf getV_Click 
Else 
   img.Enabled = False 
End If 
TC.Controls.Add(img) 

When I click on one of the LinkButtons, I run this code:

Dim script As String = "" 
script = [String].Format("return ShowSessionEditForm('{0}');", e.ReturnID) 
Page.ClientScript.RegisterStartupScript(Page.GetType(), "mykey", script, True

But after this, I get another javascript error in Firebug

return not in function (In IE, the error name is: 'return' statement outside of the function)
return ShowSessionEditForm('2685');Sys.Application.initialize();\n

So it seems that the getAbbrMonthIndex error is somehow related to this problem here.
I tried two techniques concerning the javascript function ShowSessionEditForm (both of them working in other pages of my web app):

function ShowSessionEditForm(idSession) {  
   window.radopen("SessionManagementEdit.aspx?session=" + idSession, "SessionEditDialog");  
   return false;  
}  
  
function ShowSessionEditForm(idSession) {  
   var parentPage = GetRadWindow().BrowserWindow;  
   var parentRadWindowManager = parentPage.GetRadWindowManager();  
   var oWnd2 = parentRadWindowManager.open("SessionManagementEdit.aspx?session=" + idSession, "SessionEditDialog");  
   window.setTimeout(function() {  
      oWnd2.setActive(true);  
   }, 0);  

Any thoughts on this?
Thanks again,

Ricardo.

Ps: meanwhile, some of the (many, many) info Firebug shows pointed me to the grid in Aspx1. Four of the columns had this attribute DataFormatString={0:d}. I removed this instruction in each of the grid columns and the first getAbbrMonthIndex error I talked about, which occurred during the aspx2 loading, disapeared! And even after adding again the DataFormatString, it never showed up again. Strange!
0
Nik
Top achievements
Rank 1
answered on 06 May 2009, 02:49 PM
Replace

Dim script As String = "" 
script = [String].Format("return ShowSessionEditForm('{0}');", e.ReturnID) 
Page.ClientScript.RegisterStartupScript(Page.GetType(), "mykey", script, True


By

Dim script As String = "" 
script = [String].Format("ShowSessionEditForm('{0}');", e.ReturnID) 
Page.ClientScript.RegisterStartupScript(Page.GetType(), "mykey", script, True


your original markup will render on the page as

<script type="text/javascript">
return ShowSessionEditForm(22834882);
</script>

Which is incorrect since there is no function from which you are returning.

Hope this helps.



0
Ricardo Pinto
Top achievements
Rank 1
answered on 06 May 2009, 03:14 PM

I tried your solution, and it worked :D

Removing "return" in the code-behind and using this version of the javascript function:

function ShowSessionEditForm(idSession) {  
   var parentPage = GetRadWindow().BrowserWindow;  
   var parentRadWindowManager = parentPage.GetRadWindowManager();  
   var oWnd2 = parentRadWindowManager.open("SessionManagementEdit.aspx?session=" + idSession, "SessionEditDialog");  
   window.setTimeout(function() {  
      oWnd2.setActive(true);  
   }, 0);  

Thank you very much, Nik!
Best regards,

Ricardo.






Ps: Using the other version of the javascript function, I got the following error in firebug:
_1f is undefined
radopen()("SessionManagementEdit.aspx?session=2686", "SessionEditDialog")ScriptRe...=53f5b61a (line 57)
ShowSessionEditForm("2686")SessionM...695111395 (line 134)
return _1f.open(url,_1e);


0
Nik
Top achievements
Rank 1
answered on 06 May 2009, 03:18 PM
I am glad I could help :)

If you need anymore help with anything in general either leave a comment in this thread or catch me on www.matrixconnects.com or www.britishpcrepairs.co.uk
0
Kapil
Top achievements
Rank 1
answered on 12 Sep 2012, 06:29 AM
Hi Nick,

I changed the code as suggested and added updated dll in project solution which pasted below, but it didn't work.

if (Sys.CultureInfo.prototype._getAbbrMonthIndex) {
try {
        var del = Function.createDelegate(Sys.CultureInfo.CurrentCulture != null ? Sys.CultureInfo.CurrentCulture : Sys.CultureInfo.InvariantCulture, Sys.CultureInfo.prototype._getAbbrMonthIndex);
        del('');

    } catch (ex) {
        Sys.CultureInfo.prototype._getAbbrMonthIndex = function(b) {
            var a = this;
            if (!a._upperAbbrMonths) a._upperAbbrMonths = a._toUpperArray(a.dateTimeFormat.AbbreviatedMonthNames);
            return Array.indexOf(a._upperAbbrMonths, a._toUpper(b))
        };
        Sys.CultureInfo.CurrentCulture._getAbbrMonthIndex = Sys.CultureInfo.prototype._getAbbrMonthIndex;
        Sys.CultureInfo.InvariantCulture._getAbbrMonthIndex = Sys.CultureInfo.prototype._getAbbrMonthIndex;
    }
};

Is there anything more that needs to be done ?

- Kapil
0
Sergio
Top achievements
Rank 1
answered on 21 Feb 2013, 03:13 PM
The error occurs with Firefox 19.0 and Firebug 1.10.2. The problem does not stop the execution of the page, but if you have Firebug enabled "Stop on all errors" often stops at that line.

Suffice you to change the function like this:

 function Sys$CultureInfo$_getAbbrMonthIndex(value) {
        if (!this._upperAbbrMonths) {
            if(!this.dateTimeFormat)
            {
                return value;
            }
            this._upperAbbrMonths = this._toUpperArray(this.dateTimeFormat.AbbreviatedMonthNames);
        }
        return Array.indexOf(this._upperMonths, this._toUpper(value));
    }

Anyway, the problem occurs when i use Calendarextender.
0
Sergio
Top achievements
Rank 1
answered on 01 Mar 2013, 03:57 PM
Problem occurs when usin ScriptManager whit ScriptMode = Debug. If I defined ScriptMode="Release", the problem disappears.
Tags
TreeView
Asked by
bkj
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Brian
Top achievements
Rank 2
Val
Top achievements
Rank 1
Veselin Vasilev
Telerik team
cmarsh
Top achievements
Rank 1
Iron
Mark
Top achievements
Rank 1
Nik
Top achievements
Rank 1
Ricardo Pinto
Top achievements
Rank 1
Kapil
Top achievements
Rank 1
Sergio
Top achievements
Rank 1
Share this question
or