开发者

How to show/hide progressbar for PageMethods?

开发者 https://www.devze.com 2023-04-01 06:05 出处:网络
I am developing a web application using asp.net framework 4.0. I am using so many PageMethods in my application i.e my application is fully ajax enabled. I am not using UpdatePanel to avoid page parti

I am developing a web application using asp.net framework 4.0. I am using so many PageMethods in my application i.e my application is fully ajax enabled. I am not using UpdatePanel to avoid page partial postback. In my scenario i want to show progressbar when an AJAX request is made by PageMethods. I cant use UpdateProgress as It is associated with UpdatePanel which i am not using. I can show progress bar before calling a function & onsuccess i can hide it. like

function CallPageMethod()
{
   $("#progressDiv").show();
   PageMethods.GetCurrentDate(Onsuccess);
}

function Ons开发者_开发百科uccess(result)
{
      $("#progressDiv").hide();
      alert(result);
}

This methods works fine but its very difficult for me to write show & hide code for each & every pagemethods. As my page contains so many PageMethods. How do i write a common method which will show/hide progressbar for each AJAX request?


if you are looking for a way to isolate and share calls to progress bar hide and show in a common method, surely you can have a JS function which does the $("#progressDiv").show() or $("#progressDiv").hide() for everybody. such function could even be the same and accept a bool visible as parameter than from every PageMethod calling place and in every OnSuccess you will call this function.

I think you cannot really do much more because in fact every page method invokation would need to be different and also every OnSuccess could behave differently depening on the case so those handlers have to be separated.

0

精彩评论

暂无评论...
验证码 换一张
取 消