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);
}

Tuesday, September 16, 2008

AutoCompleteExtender iframe problem

In AjaxToolKit there is an Extender that allows to set your textBox to work as auto complete control. it works just fine if you don't work with IE. IE has a problem, if you have a listbox under the list of autocompele suggestions , the suggestions will not be shown (they will be under the listbox), to fix this autocomplete extender has an iframe that should be bellow the suggestions list.
this should fix the IE bug, but to do that, you should add some manual code to you Extender, because if the width of the suggection list changes the if does not change his width or higth.
to fix this bug, add the following code.

1. add the event to your extender .
OnClientShown = "AutoComplereSearch_Show"

2. the AutoComplereSearch_Show
function AutoComplereSearch_Show(sender,args)
{
var oList = sender.get_completionList();
var oSpan= GetMainSpan(oList); // auto compelete is surrounded with 'span'.
var iframe = oSpan.getElementsByTagName('IFRAME')[0];
iframe.style.width = oList.style.width;
iframe.style.height = oList.offsetHeight;
}

function GetMainSpan(oObj)
{
var oParent = oObj.parentElement;
while (oParent.tagName!='SPAN')
{
oParent = oParent.parentElement;
}
return oParent;
}

Tuesday, September 2, 2008

convert your project from framework 1 to framework 2

When i converted my asp.net project to framework 2 , i discovered that the style of my web project got messed, and after hard work of repairing the css, i found coincidentally that vs 2005 created new pages with XHTML standard and vs 2003 with HTML 4.
so i changed the standard in my master page to HTML 4 and magically all of my css problems disappeared .