[FIXED] Microsoft ScriptManager and Date Format

  1. #1

    [FIXED] Microsoft ScriptManager and Date Format

    Hello,

    The following example demonstrates an inconsistency between the Microsoft ASP.NET ScriptManager and the scripts it automatically loads, and the ExtJS Date.format function.

    Check out the following simplified example, this one took me a couple hours to track:

    <%@ Page Language="C#" %>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <script runat="server">
    
        protected void Page_Load(object sender, EventArgs e)
        {
            Coolite.Ext.Web.ScriptManager.GetCurrent(Page).RegisterAfterClientInitScript("getStartDate()");
        }
        
    </script>
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>Untitled Page</title>
        <script type="text/javascript">
            function getStartDate() {
                var startDate = Date.parseDate('2009-01-01T00:00:00', 'Y-m-dTh:i:s');
                var format = 'l M. jS, Y';
                
                alert(startDate.format(format));
            }
        </script>
    </head>
    <body>
        <form id="form1" runat="server">
            <asp:ScriptManager runat="server" />
            <ext:ScriptManager runat="server" />
        </form>
    </body>
    </html>
    Replication steps:

    1. Load page
    2. Notice the format is incorrect?
    3. Remove <asp:ScriptManager runat="server" />
    4. Reload page
    5. Corrected

    The Date.format function only works as expected when a Microsoft ASP.NET ScriptManager is not loaded on the page.

    Cheers,
    Timothy
  2. #2

    RE: [FIXED] Microsoft ScriptManager and Date Format

    Works if I use the following:

     ... Ext.util.Format.date(startDate, format) ...
    Cheers,
    Timothy
  3. #3

    RE: [FIXED] Microsoft ScriptManager and Date Format

    For people who do not want to change their code because of that problem/bug/missing feature ...

    Calling:

    Date.prototype.format = Date.prototype.dateFormat;
    as late as possible (but not too late ;-) ) should also work as workaround.

Similar Threads

  1. Replies: 3
    Last Post: May 09, 2012, 4:28 PM
  2. Replies: 1
    Last Post: Apr 13, 2012, 1:52 PM
  3. [CLOSED] Serialized Microsoft Date Format
    By mkshields9w57 in forum 1.x Help
    Replies: 8
    Last Post: Jul 29, 2011, 5:17 PM
  4. Interesting comment by Microsoft on String.Format Issue
    By pkellner in forum Open Discussions
    Replies: 1
    Last Post: Dec 11, 2008, 1:59 PM
  5. Replies: 8
    Last Post: Jun 06, 2008, 1:28 AM

Posting Permissions