localeFormat.aspx 1.5 KB

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