开发者

How can I invoke a javascript trhough a thread?

I have a thread that runs querying a DB and returning some values. If this values satisfyes a condition, I want to raise a message box (javascript alert) for the client side.

In my system, users can post some tasks in DB, and the thread is going to constantly query the database to check if user has things to do. If user has, the system must alert him through a message box. The text is very simple, and statik, like "Hey, dude, go work, lazy!" (I'm joking, the message shall be like "You have new task(s). Please check.") Just it!

I've done javascripts invokings with ClientScript.Regi开发者_运维技巧sterStartupScript, and Attributes.Add for buttons. But now I want to call the javascript functions (wich will alert the user that he has things to do) from the midle of a sub (that is executed in a thread), without a submit, load or click event. How can I do it?

Thanks!


You can't call a client side script directly from the server side code.

The best you can do is use AJAX and poll the server to see when an operation completes and at that point call your javascript function.


Take a look at this article (its fairly dated) but is close to what you want to do.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜