Guest User

Untitled

a guest
Dec 18th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.71 KB | None | 0 0
  1. $(function() {
  2. $('div._Foo').bind("mouseover", function(e) {
  3. // Do something exciting
  4. });
  5. });
  6.  
  7. $(document).ready(function() {
  8. // bind your jQuery events here initially
  9. });
  10.  
  11. var prm = Sys.WebForms.PageRequestManager.getInstance();
  12.  
  13. prm.add_endRequest(function() {
  14. // re-bind your jQuery events here
  15. });
  16.  
  17. <script type="text/javascript">
  18.  
  19. function BindEvents() {
  20. $(document).ready(function() {
  21. $(".tr-base").mouseover(function() {
  22. $(this).toggleClass("trHover");
  23. }).mouseout(function() {
  24. $(this).removeClass("trHover");
  25. });
  26. }
  27. </script>
  28.  
  29. <asp:UpdatePanel...
  30. <ContentTemplate
  31. <script type="text/javascript">
  32. Sys.Application.add_load(BindEvents);
  33. </script>
  34. *// Staff*
  35. </ContentTemplate>
  36. </asp:UpdatePanel>
  37.  
  38. <script type="text/javascript">
  39. function BindControlEvents() {
  40. //jQuery is wrapped in BindEvents function so it can be re-bound after each callback.
  41. //Your code would replace the following line:
  42. $('#<%= TextProtocolDrugInstructions.ClientID %>').limit('100', '#charsLeft_Instructions');
  43. }
  44.  
  45. //Initial bind
  46. $(document).ready(function () {
  47. BindControlEvents();
  48. });
  49.  
  50. //Re-bind for callbacks
  51. var prm = Sys.WebForms.PageRequestManager.getInstance();
  52.  
  53. prm.add_endRequest(function() {
  54. BindControlEvents();
  55. });
  56.  
  57. </script>
  58.  
  59. $(function() {
  60.  
  61. $('div._Foo').live("mouseover", function(e) {
  62. // Do something exciting
  63. });
  64.  
  65. });
  66.  
  67. <asp:UpdatePanel runat="server" ID="myUpdatePanel">
  68. <ContentTemplate>
  69.  
  70. <script type="text/javascript" language="javascript">
  71. function pageLoad() {
  72. $('div._Foo').bind("mouseover", function(e) {
  73. // Do something exciting
  74. });
  75. }
  76. </script>
  77.  
  78. </ContentTemplate>
  79. </asp:UpdatePanel>
  80.  
  81. function pageLoad() {
  82.  
  83. $(document).ready(function(){
  84.  
  85. $(document).ready(function() {
  86.  
  87. // Do something exciting
  88.  
  89. var prm = Sys.WebForms.PageRequestManager.getInstance();
  90.  
  91. prm.add_endRequest(function() {
  92. // re-bind your jQuery events here
  93. });
  94.  
  95. });
  96.  
  97. var prm = Sys.WebForms.PageRequestManager.getInstance();
  98. prm.add_endRequest(function() {...
  99.  
  100. <script type="text/javascript" language="javascript">
  101. function pageLoad() {
  102. // Initialization code here, meant to run once.
  103. }
  104. </script>
  105.  
  106. pageLoad = function () {
  107. $('#div').unbind();
  108. //jquery here
  109. }
  110.  
  111. <script type="text/javascript">
  112. var prm = Sys.WebForms.PageRequestManager.getInstance();
  113. prm.add_endRequest(EndRequestHandler);
  114. function EndRequestHandler(sender, args) {
  115. if (args.get_error() == undefined) {
  116. UPDATEPANELFUNCTION();
  117. }
  118. }
  119.  
  120. function UPDATEPANELFUNCTION() {
  121. jQuery(document).ready(function ($) {
  122. /* Insert all your jQuery events and function calls */
  123. });
  124. }
  125.  
  126. UPDATEPANELFUNCTION();
  127.  
  128. </script>
  129.  
  130. Sys.WebForms.PageRequestManager.getInstance().add_endRequest(onEndRequest)
  131. function onEndRequest(sender, args) {
  132. // your jquery code here
  133. });
  134.  
  135. private void ShowForm(bool pShowForm) {
  136. //other code here...
  137. if (pShowForm) {
  138. FocusOnControl(GetFocusOnFormScript(yourControl.ClientID), yourControl.ClientID);
  139. }
  140. }
  141.  
  142. private void FocusOnControl(string pScript, string pControlId) {
  143. ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "focusControl_" + pControlId, pScript, true);
  144. }
  145.  
  146. /// <summary>
  147. /// Scrolls to the form that is made visible
  148. /// </summary>
  149. /// <param name="pControlId">The ClientID of the control to focus on after the form is made visible</param>
  150. /// <returns></returns>
  151. private string GetFocusOnFormScript(string pControlId) {
  152. string script = @"
  153. function FocusOnForm() {
  154. var scrollToForm = $('#" + pControlId + @"').offset().top;
  155. $('html, body').animate({
  156. scrollTop: scrollToForm},
  157. 'slow'
  158. );
  159. /* This removes the event from the PageRequestManager immediately after the desired functionality is completed so that multiple events are not added */
  160. prm.remove_endRequest(ScrollFocusToFormCaller);
  161. }
  162. prm.add_endRequest(ScrollFocusToFormCaller);
  163. function ScrollFocusToFormCaller(sender, args) {
  164. if (args.get_error() == undefined) {
  165. FocusOnForm();
  166. }
  167. }";
  168. return script;
  169. }
  170.  
  171. Sys.Application.add_load(LoadHandler); //This load handler solved update panel did not bind date picker after partial postback
  172. function LoadHandler() {
  173. $(document).ready(function () {
  174. //rebind any events here for controls under update panel
  175. });
  176. }
Add Comment
Please, Sign In to add comment