default.aspx 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. <%@ Page Language="C#" %>
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  3. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  4. <script runat="server">
  5. protected void LinkButton_Click(object sender, EventArgs e)
  6. {
  7. TextBox1.Text = DateTime.Now.ToString();
  8. }
  9. </script>
  10. <html xmlns="http://www.w3.org/1999/xhtml">
  11. <head id="Head1" runat="server">
  12. <title>PageRequestManager pageLoaded Event Example</title>
  13. <style type="text/css">
  14. body {
  15. font-family: Tahoma;
  16. }
  17. .FieldSetStyle
  18. {
  19. width: 300px;
  20. height: 100px;
  21. }
  22. .UpdatePanelContainer
  23. {
  24. width: 330px;
  25. height:110px;
  26. }
  27. </style>
  28. </head>
  29. <body>
  30. <form id="form1" runat="server">
  31. <asp:ScriptManager ID="ScriptManager1" runat="server" />
  32. <script type="text/javascript">
  33. Type.registerNamespace("ScriptLibrary");
  34. ScriptLibrary.BorderAnimation = function(color, duration) {
  35. this._color = color;
  36. this._duration = duration;
  37. }
  38. ScriptLibrary.BorderAnimation.prototype = {
  39. animatePanel: function(panelElement) {
  40. var s = panelElement.style;
  41. s.borderWidth = '1px';
  42. s.borderColor = this._color;
  43. s.borderStyle = 'solid';
  44. window.setTimeout(
  45. function() {{ s.borderWidth = 0; }},
  46. this._duration
  47. );
  48. }
  49. }
  50. ScriptLibrary.BorderAnimation.registerClass('ScriptLibrary.BorderAnimation', null);
  51. var panelUpdatedAnimation = new ScriptLibrary.BorderAnimation('blue', 1000);
  52. var postbackElement;
  53. Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(beginRequest);
  54. Sys.WebForms.PageRequestManager.getInstance().add_pageLoaded(pageLoaded);
  55. function beginRequest(sender, args) {
  56. postbackElement = args.get_postBackElement();
  57. }
  58. function pageLoaded(sender, args) {
  59. var updatedPanels = args.get_panelsUpdated();
  60. if (typeof(postbackElement) === "undefined") {
  61. return;
  62. }
  63. else if (postbackElement.id.toLowerCase().indexOf('external') > -1) {
  64. for (i=0; i < updatedPanels.length; i++) {
  65. panelUpdatedAnimation.animatePanel(updatedPanels[i]);
  66. }
  67. }
  68. }
  69. </script>
  70. <p>
  71. <asp:LinkButton ID="ExternalButton" runat="server" OnClick="LinkButton_Click">
  72. Update the panel with animation.
  73. </asp:LinkButton>
  74. </p>
  75. <hr />
  76. <div class="UpdatePanelContainer">
  77. <asp:UpdatePanel runat="server" ID="UpdatePanel1" UpdateMode="Conditional">
  78. <Triggers>
  79. <asp:AsyncPostBackTrigger ControlID="ExternalButton" />
  80. </Triggers>
  81. <ContentTemplate>
  82. <fieldset id="FieldSet1" class="FieldSetStyle" runat="server">
  83. <legend>UpdatePanel</legend>
  84. <asp:TextBox runat="server" ID="TextBox1" />
  85. <br />
  86. <asp:LinkButton ID="InternalButton" runat="server" OnClick="LinkButton_Click">
  87. Update the panel with no animation.
  88. </asp:LinkButton>
  89. </fieldset>
  90. </ContentTemplate>
  91. </asp:UpdatePanel>
  92. </div>
  93. </form>
  94. </body>
  95. </html>