Thursday, September 18, 2008

Manual UpdateProgress

Some times you want to set the loading gif in certain position.
you can do it in the following ways :
1. with ajax.net beginRequest event , to take the gif and calculate the position.
2. without update progress.

i will show the second way .

Sys.WebForms.PageReqestManager.getInstance().add_endRequest
(EndRequestHandler);
Sys.WebForms.PageReqestManager.getInstance().add_beginRequest
(BeginRequestHandler);
var iframe;
function SetIframe
(obj,id,src,width,height,allowtransparency,left,top)
{
obj.id = id;
obj.style.posTop = top;
obj.frameBorder = '0';
obj.src = src;
obj.style.width = width;
obj.style.height = height;
obj.style.display = 'block';
obj.style.position = 'absolute';
obj.allowTransparency = allowtransparency;
}

function SetProgressIframe()
{
iframe = document.createElement('IFRAME');
SetIframe(iframe,'ProgressIframe',poputWait.aspx',
'160px','70px',false,window.document.body.clientWidth/2-70,
window.document.body.clientHeight/2-20);
document.forms[0].appendChild(iframe);
}

function BeginRequestHandler(sender,args)
{
setProgressIframe();
}

function EndRequestHandler(sender,args)
{
iframe.style.display = 'none';
document.forms[0].removeChild(iframe);
}

No comments: