localeFormat.aspx 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. <%@ Page Language="C#" %>
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml">
  4. <head runat="server">
  5. <title>Globalization Example</title>
  6. </head>
  7. <body>
  8. <form id="form1" runat="server">
  9. <asp:ScriptManager ID="ScriptManager1" runat="server" EnableScriptGlobalization="true"/>
  10. <asp:UpdatePanel ID="UpdatePanel1" runat="server" ChildrenAsTriggers="False"
  11. UpdateMode="Conditional">
  12. <ContentTemplate>
  13. <asp:Panel ID="Panel1" runat="server" GroupingText="Update Panel">
  14. <asp:Button ID="Button1" runat="server" Text="Display Date" />
  15. <br />
  16. <asp:Label ID="Label1" runat="server"></asp:Label>
  17. </asp:Panel>
  18. </ContentTemplate>
  19. </asp:UpdatePanel>
  20. </form>
  21. </body>
  22. </html>
  23. <script type="text/javascript">
  24. Sys.UI.DomEvent.addHandler($get("Button1"), "click", formatDate);
  25. function formatDate() {
  26. // Thursday, 14 January 2010 00:10:00
  27. var d = new Date(2010, 0, 14, 0, 10);
  28. try {
  29. $get('Label1').innerHTML = d.localeFormat("dddd, dd MMMM yyyy HH:mm:ss");
  30. }
  31. catch(e) {
  32. alert("Error:" + e.message);
  33. }
  34. }
  35. </script>