开发者

Action without Page_Load

Is there anyway to开发者_C百科 perform a timely action in ASP.NET using a timer but without page load. Simply to run some silent back ground activities.

Do .ascx files help me running such activities?


you can use jQuery like below

window.setInterval(yourfunction, 10000);

function yourfunction() { alert('test'); }

or use Timer Control in AJAX

EDIT:

if you don't need to load any page then try this out "Easy Background Tasks in ASP.NET"


I don't know what kind of background activities you'd like to run, but maybe you can use the jQuery timer plugin? Use the .Everytime method :

http://plugins.jquery.com/project/timers


If you need to run this background activities on client side I recommend to look over @stekkie answer.

If you need to run on server side, you could use UpdatePanel with a timer to accomplish your objective. Check this for more details on how to do it. http://msdn.microsoft.com/en-us/library/cc295400(v=Expression.40).aspx

You can just have this update panel with nothing inside it and on server side, you just implement the OnTick event of the timer control and run the code you need.

.ascx files are not going to help you run background activities.


It depends on what kind of background activities you're looking to run. Page level is usually not the place to perform background operations. From the way you're describing it, it sounds like you should look into creating a service for your background operations.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜