Sunday, March 23, 2008

Some Ajax tips & tricks

Display an hourglass

var prm = Sys.WebForms.PageRequestManager.getInstance();
prm.add_initializeRequest(InitializeRequest);
prm.add_endRequest(EndRequest);
function InitializeRequest(sender, args) {
document.body.style.cursor = "wait";
}
function EndRequest(sender, args) {
document.body.style.cursor = "default";
}

Click-once button control

var prm = Sys.WebForms.PageRequestManager.getInstance();
prm.add_initializeRequest(InitializeRequest);
prm.add_endRequest(EndRequest);

var btn;

function InitializeRequest(sender, args)
{
document.body.style.cursor = "wait";
var btnId=args._postBackElement.id;
btn= document.getElementById(btnId);
if (btn.type=="button" || btn.type=="submit")
btn.disabled=true;
}

function EndRequest(sender, args)
{
document.body.style.cursor = "default";
if(btn!=null) btn.disabled=false;
}

Code explanation:

In the InitializeRequest function we retrieve the pressed button id, by retrieving the _postBackElement which is passed as an argument, and after we verify if it is a button. We must declare the button variable as a global variable, to allow the EndRequest function to know which button fires the event.
Note that the above function will work ONLY if the button control is inside an UpdatePanel. And that's it! We have a click-once button! We can even put it in a MasterPage to propagate behavior to your content pages...

Sunday, March 16, 2008

HIT MAN




The "Hitman" is a genetically-engineered, elite assassin known only as Agent 47. His hallmarks are lethal grace, unwavering precision, and resolute pride in his work. But even 47 couldn't anticipate a "random equation" in his life exactitude: the unexpected stirrings of his conscience and the unfamiliar emotions aroused in him by a mysterious Russian woman.



Genres: Action/Adventure, Crime/Gangster and Adaptation


Running Time: 1 hr. 33 min.


Release Date: November 21st, 2007 (wide)


MPAA Rating: R for strong bloody violence, language, and some sexuality/nudity.


Distributors: 20th Century Fox Distribution