PDA

View Full Version : [FIXED] Microsoft ScriptManager and Date Format



Timothy
Apr 05, 2009, 11:43 AM
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).Reg isterAfterClientInitScript("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

Timothy
Apr 06, 2009, 7:08 PM
Works if I use the following:



... Ext.util.Format.date(startDate, format) ...


Cheers,
Timothy

macap
Mar 17, 2010, 10:29 AM
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.