this.datetimeformat is undefined error in firefox

22 posts, 0 answers
  1. bkj
    bkj avatar
    8 posts
    Member since:
    Nov 2006

    Posted 07 Oct 2008 Link to this post

    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
  2. Atanas Korchev
    Admin
    Atanas Korchev avatar
    8462 posts

    Posted 09 Oct 2008 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Brian
    Brian avatar
    8 posts
    Member since:
    Oct 2008

    Posted 13 Nov 2008 Link to this post

    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?
  5. Val
    Val avatar
    18 posts
    Member since:
    Aug 2007

    Posted 24 Jan 2009 Link to this post

    Any solution to this problem?
  6. Veselin Vasilev
    Admin
    Veselin Vasilev avatar
    2992 posts

    Posted 26 Jan 2009 Link to this post

    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.
  7. Val
    Val avatar
    18 posts
    Member since:
    Aug 2007

    Posted 26 Jan 2009 Link to this post

    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.
  8. Val
    Val avatar
    18 posts
    Member since:
    Aug 2007

    Posted 26 Jan 2009 Link to this post

    I got it.

    http://www.telerik.com/help/aspnet-ajax/ajxerrorhandling.html
  9. cmarsh
    cmarsh avatar
    14 posts
    Member since:
    Oct 2006

    Posted 30 Jan 2009 Link to this post

    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);

     

     

    }

     

  10. Veselin Vasilev
    Admin
    Veselin Vasilev avatar
    2992 posts

    Posted 02 Feb 2009 Link to this post

    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.
  11. cmarsh
    cmarsh avatar
    14 posts
    Member since:
    Oct 2006

    Posted 02 Feb 2009 Link to this post

    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);

     

  12. Veselin Vasilev
    Admin
    Veselin Vasilev avatar
    2992 posts

    Posted 05 Feb 2009 Link to this post

    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.
  13. Mark
    Mark avatar
    1 posts
    Member since:
    Mar 2009

    Posted 10 Mar 2009 Link to this post

    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)

     

  14. Nik
    Nik avatar
    4 posts
    Member since:
    Apr 2009

    Posted 22 Apr 2009 Link to this post

    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!
  15. Ricardo Pinto
    Ricardo Pinto avatar
    36 posts
    Member since:
    Sep 2008

    Posted 06 May 2009 Link to this post

    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.



  16. Nik
    Nik avatar
    4 posts
    Member since:
    Apr 2009

    Posted 06 May 2009 Link to this post

    Hi Ricardo

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

  17. Ricardo Pinto
    Ricardo Pinto avatar
    36 posts
    Member since:
    Sep 2008

    Posted 06 May 2009 Link to this post


    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!
  18. Nik
    Nik avatar
    4 posts
    Member since:
    Apr 2009

    Posted 06 May 2009 Link to this post

    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.



  19. Ricardo Pinto
    Ricardo Pinto avatar
    36 posts
    Member since:
    Sep 2008

    Posted 06 May 2009 Link to this post


    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);


  20. Nik
    Nik avatar
    4 posts
    Member since:
    Apr 2009

    Posted 06 May 2009 Link to this post

    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
  21. Kapil
    Kapil avatar
    1 posts
    Member since:
    Sep 2012

    Posted 12 Sep 2012 Link to this post

    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
  22. Sergio
    Sergio avatar
    2 posts
    Member since:
    Feb 2013

    Posted 21 Feb 2013 Link to this post

    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.
  23. Sergio
    Sergio avatar
    2 posts
    Member since:
    Feb 2013

    Posted 01 Mar 2013 Link to this post

    Problem occurs when usin ScriptManager whit ScriptMode = Debug. If I defined ScriptMode="Release", the problem disappears.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017