﻿/*----------------------------------------------------------------------------
 Project:			OnlineShopDotNet
 Source File:		DisableAjaxPostBackControl.js
 Company:     		Ascent Technology Limited
 Author:      		John Mills
 Date:        		24/08/2007
 Purpose:     		This file contains code that registers an AJAX event handler
						that disables controls that trigger an asynchronous post 
						back to prevent duplicate postbacks (e.g. user tries to
						click button more than once) and provides a visual cue that
						something is happening.
 Notes:       		
------------------------------------------------------------------------------
 John Mills     	Created.
 22/08/2007        
----------------------------------------------------------------------------*/

Sys.Application.add_load(ApplicationLoadHandler)

/*
	Application Load event handler.
*/
function ApplicationLoadHandler(sender, args)
{
   var prm = Sys.WebForms.PageRequestManager.getInstance();
   
   prm.add_initializeRequest(InitializeRequest);
   Sys.Application.remove_load(ApplicationLoadHandler)
   
}
  
/*
	Executed anytime an async postback occurs. Changes the post back control state to disabled.
	It helps prevent multiple postbacks and provides a visual cue.
*/
function InitializeRequest(sender, args) 
{
	var postBackElementId = args.get_postBackElement().id
	
	if (postBackElementId) $get(postBackElementId).disabled = true;	

}

// Notify ScriptManager that this is the end of the script.
if (typeof(Sys) !== 'undefined') Sys.Application.notifyScriptLoaded();