PageAsyncTask endHandler 更新调用页面

发布于 2024-09-12 03:19:30 字数 229 浏览 3 评论 0原文

我被迫应用 Microsoft 的 PageAsyncTask 对象,这是我的新手(之前我一直使用 jQuery AJAX 调用)。我已经让一切正常工作,除了工作完成并调用 endHandler 后,如何让调用页面更新其内容?

基本上,我的异步函数运行大量数据库操作,并用 HTML 向调用者报告数据库运行的结果。我想在操作完成后在调用页面上显示这些结果。除了显示结果的调用页面之外,一切都正常。

感谢您的帮助。

I've been coerced into applying Microsoft's PageAsyncTask objects, which I am new to (before I've always used jQuery AJAX calls). I've got everything working just right except once the work is done and the endHandler is called, how do I have the calling page update its contents?

Basically my async function runs a slew of database operations and reports back to the caller with HTML regarding the results of the database run. I'd like to display these results on the calling page once the operation has completed. I have everything working except the calling page displaying the results.

Your help is appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

江南月 2024-09-19 03:19:30

使用RegisterAsyncTask使asp.net页面生命周期异步,但从浏览器的角度来看,HttpRequest仍然是同步的。本质上,当您在 ASP.NET 页面中使用 AsyncTasks 时,它的行为与任何其他 ASP.NET 页面完全相同,只不过在这些异步操作期间,线程会返回到 IIS,以便其他请求可以使用它。

因此,您的异步操作不一定返回 HTML,因为它的调用者不是浏览器;您仍然处于原始 asp.net 页面调用的生命周期内。我相信您的异步回调可以将数据库结果直接应用到页面上的各种控件,就像您没有异步实现操作一样。

Using RegisterAsyncTask makes the asp.net page lifecycle asynchronous, but from the browser's perspective, the HttpRequest is still synchronous. Essentially, when you use AsyncTasks in your asp.net page, it behaves exactly as any other asp.net page, except that during those async operations, the thread is returned to IIS so it can be used by other requests.

Therefore, your async operation shouldn't necessarily return HTML, because its caller isn't the browser; you're still within the lifecycle of the original asp.net page call. I believe your async callback can apply the DB results directly to the various controls on the page, same as you would if you hadn't implemented the operation asynchronously.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文