当究竟Page.RegisterAsyncTask的get叫什么名字? [英] When exactly do Page.RegisterAsyncTask's get called?

查看:351
本文介绍了当究竟Page.RegisterAsyncTask的get叫什么名字?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到涉及与RegisterAsyncTask,ViewState中,和复选框ASP.NET页面上注册异步code混乱的行为,我需要知道什么时候这些异步任务运行时的相对视图状态保存到。

I am running into confusing behavior related to async code registered on an ASP.NET page with RegisterAsyncTask, ViewState, and checkboxes, and I need to know exactly when these async-tasks run relative to when ViewState is saved.

我有一个ASP内部少数几个复选框:占位符的控制。我读的记录和填充的复选框,然后我做占位符可见。

I have a few checkboxes inside an ASP:PlaceHolder control. I am reading a record and populating the checkboxes, then I make the PlaceHolder visible.

如果这一切是同步的 - 也许在Page_Load中 - 一切都很好。

If all this is synchronous - maybe within Page_Load - all is well.

如果这被注册为异步任务会发生以下情况:

If this is registered as an async task the following happens:


  1. 的复选框得到填充。

  2. 的占位符是可见的。

  3. 在回传,复选框不能听之任之。也就是说,如果他们最初检查它们保留,即使用户未选中他们自己的检查状态。这似乎是复选框恢复到初始值。如果一个复选框在客户端上选中,这使得它!取消选中没有。

这似乎并不符合文本框的一个问题。我还没有尝试过其他的部件。

This doesn't seem to be a problem with textboxes. I haven't tried other widgets.

我能正确的这一问题通过设置占位符来之前我注册异步任务是可见的。我认为这是类似于我对电网的可见的其他问题:

I can 'correct' this problem by setting the PlaceHolder to be visible BEFORE I register the async task. I think this is similar to my other question about Grid visiblity:

的asp:DataGrid中的知名度与异步

它谈到了将非常困难,导致混乱code作为我试着拉所有的可视性规则出异步方法。

It's turning out to be very difficult and resulting in confusing code as I try to pull all the visiblity-rules out of async methods.

我从沾到preRender之前保存某个ASP.NET页面的生命周期看。我也认为的RegisterAsyncTask'd code获取运行大约在同一时间。这确实发生在什么样的顺序?如果ViewState是我的code运行之前保存的我击沉!

I see from the ASP.NET page lifecycle that gets saved sometime before OnPreRender. I also think RegisterAsyncTask'd code gets run about the same time. What order does this happen in? If ViewState is saved before my code runs I'm sunk!

编辑:我发现了一些细节,但它仍然是令人困惑:
中途下此页:<一href=\"http://www.asp.net/web-forms/overview/performance-and-caching/using-asynchronous-methods-in-aspnet-45\" rel=\"nofollow\">http://www.asp.net/web-forms/overview/performance-and-caching/using-asynchronous-methods-in-aspnet-45它说:

I found some more detail but it is still confusing: Halfway down this page: http://www.asp.net/web-forms/overview/performance-and-caching/using-asynchronous-methods-in-aspnet-45 it says

迷上了RegisterAsyncTask的方法将后preRender立即运行。

"Methods hooked up with RegisterAsyncTask will run immediately after PreRender."

本页面: https://开头MSDN。 microsoft.com/en-us/library/ms178472(v=vs.85).aspx 详细介绍了preRender和SaveStateComplete事件,但没有提及RegisterAsyncTask。我需要通过实验来看看它们之间如果鞋子有角的。

This page: https://msdn.microsoft.com/en-us/library/ms178472(v=vs.85).aspx details the PreRender and SaveStateComplete events but doesn't mention RegisterAsyncTask. I need to experiment to see if its shoe-horned between them.

推荐答案

的<一个href=\"https://msdn.microsoft.com/en-us/library/system.web.ui.page.executeregisteredasynctasks(v=vs.110).aspx\"相对=nofollow> ExecuteRegisteredAsyncTasks 给你时,被启动的任务在一些更多的控制。

The ExecuteRegisteredAsyncTasks gives you some more control in when the tasks are being started.

ExecuteRegisteredAsyncTasks 方法是自动调用的
  在页面加工点时,任何注册异步任务,
  如果存在的话,被调用了的非异步页的。 这种自动
  来电 ExecuteRegisteredAsyncTasks 前刚刚发生
   preRenderComplete 事件。

The ExecuteRegisteredAsyncTasks method is automatically called at the point in the page processing when any registered asynchronous tasks, if they exist, are invoked for a non-asynchronous page. This automatic call to ExecuteRegisteredAsyncTasks occurs just before the PreRenderComplete event.

从的 preRenderComplete 文档:

这是页的视图状态保存之前提出的最后一个事件。

This is the last event raised before the page's view state is saved.

这篇关于当究竟Page.RegisterAsyncTask的get叫什么名字?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆