PostBack Ritalin is an ASP.NET AJAX server control to help simplify the common task of disabling buttons during partial postbacks.
PostBack Ritalin depends on the ASP.NET AJAX extensions. If you’re using ASP.NET 3.5, you’re all set. If you’re using ASP.NET 2.0, make sure you have the AJAX extensions property installed and configured before attempting to use PostBack Ritalin.
PreloadWaitImages: Boolean value which controls preloading of WaitImages. Defaults to true.
WaitImage: String value specifying an alternate image URL to be displayed during partial postbacks. If this is not specified, ImageButtons will be functionally disabled, but visibly unchanged during partial postbacks.
WaitText: String value specifying replacement text for any Button controls, displayed only during partial postbacks (e.g. “Please Wait”, “Processing…”, etc). If omitted, defaults to “Processing…”.
MonitoredUpdatePanels: An optional collection of UpdatePanels to monitor. If specified, then only the specified UpdatePanels will activate PostBack Ritalin. If omitted, any UpdatePanel on the page will active PostBack Ritalin. See usage example and sample website for syntax.
DisableAllElements: If the DisableAllElements property of a MonitoredUpdatePanel is set to true, partial postbacks raised within that UpdatePanel will disable all of the Button, ImageButton, and LinkButton controls inside that UpdatePanel instead of just the one that triggered the partial postback.
UpdatePanelID: The control ID of the UpdatePanel to monitor.
WaitImage: Same functionality as the master WaitImage, but specific to the particular UpdatePanel specified by UpdatePanelID.
WaitText: Same functionality as the master WaitText, but specific to the particular UpdatePanel specified by UpdatePanelID.
Basic usage. In the following example, when Button1 is clicked, its text will be replaced with “Processing…”, it will be blurred, and it will be disabled. When the partial postback completes, it will revert to its previous state.
<asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <asp:Button ID="Button1" runat="server" Text="Click Me" OnClick="Button_OnClick" /> </ContentTemplate> </asp:UpdatePanel> <encosia:PostBackRitalin runat="server" />
Example of using the MonitoredUpdatePanels collection to restrict PostBack Ritalin to only activate on events triggered from certain UpdatePanels. In the following example, only events from UpdatePanel1 will cause Button1 to be disabled during partial postbacks. Events occurring in UpdatePanel2 will be unaffected.
<asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <asp:Button ID="Button1" runat="server" Text="Click Me" OnClick="Button_OnClick" /> </ContentTemplate> </asp:UpdatePanel> <asp:UpdatePanel ID="UpdatePanel2" runat="server"> <ContentTemplate> <asp:Button ID="Button2" runat="server" Text="Click Me" OnClick="Button_OnClick" /> </ContentTemplate> </asp:UpdatePanel> <encosia:PostBackRitalin ID="PostBackRitalin1" runat="server"> <MonitoredUpdatePanels> <encosia:MonitoredUpdatePanel UpdatePanelID="UpdatePanel1" /> </MonitoredUpdatePanels> </encosia:PostBackRitalin>
- Applied J S’ update to add tests for undefined when traversing the DOM.
- Fixed issue with DisableAllElements in Master/Content pages.
- Compatibility update for ASP.NET 4.
- Added disable all elements functionality to MonitoredUpdatePanels.
- Fixed a bug in the WaitImage preloading functionality, that prevented the MonitoredUpdatePanels’ WaitImages from being preloaded.
- Fixed a problem handling postbacks raised by Button controls that have their UseSubmitBehavior property set to false.
- Improved ClientID handling in naming containers.
- By popular demand, added support for disabling LinkButtons.
- Added optional image pre-loading for WaitImages. Previously, disabled ImageButtons could take a bit too long to show their disabled image the first time, due to HTTP delay. Enabling pre-loading will cause the browser to pre-fetch and cache the disabled images, resulting in instant feedback for the disabled state.
- Several bug fixes, based on your invaluable feedback.
- Resolved all remaining issues with master pages. Nested naming containers should no longer cause any issues.
- Added the ability to provide UpdatePanel specific WaitText and WaitImage properties for each MonitoredUpdatePanel.
- Added correct handling for virtual paths in all WaitImage properties.
- Added CSS to change cursor style to “wait” when hovering over the disabled control.
- General improvements to client side code.
- Removed Toolkit dependency (no more build mismatches!).
- Added MonitoredUpdatePanels collection, to control which UpdatePanels events are handled for.
- Potentially fixed master page issues.
- Updated build to target the latest Toolkit (11119).
- Updated build to target the latest Toolkit (10920).
- Updated build to target latest Toolkit (10618).
- Added WaitImageURL, to better support ImageButton controls that raise postbacks.
- Added a check to ensure that the control raising the postback is either an ImageButton or Button type, to clear up some issues with submitting a form with enter while a Textbox is focused.
- Added a check to make sure the control that raised the postback still exists after the postback completes, in case the newly updated div no longer contains that element (e.g. a form that transitions to a confirmation message)
- Initial release