mardi 10 novembre 2009

ASP.NET

Petite astuce ASP.NET ... rien de transcendant mais, plutot utile !

Si vous utilisez une page dans laquelle il y a des "updatePanel" et que vous devez exécuter du code javascript avant l'appel ajax /et/ou après l'appel ajax, vous pouvez utiliser le PageRequestManager.

code javascript :

var pageManager = Sys.WebForms.PageRequestManager.getInstance();
pageManager.add_beginRequest(function(sender,args){
MasterPage.DisplayWaitPanel(); // affiche un hypothétique écran d'attente
return true;
});

pageManager.add_endRequest(function(sender,args){
MasterPage.HideWaitPanel(); // cache l'hypothétique écran d'attente
return true;
});

du coup le wait panel est affiché quel que soit l'action provenant de l'updatePanel !

Aucun commentaire:

Enregistrer un commentaire