Wednesday, April 08, 2009

Page.IsAsync broken on ASP.Net MVC

I was just trying to add a condition to my validation code so it would not run when the page was asynchronously posted (my controls were getting highlighted as an error before the user has even had the chance to enter any values because of some ajax that was updating another area of the page), but I found that the Page.IsAsync member is always false.

I managed to find another member that you can access via the ScriptManager:

ScriptManager.GetCurrent(Page).IsInAsyncPostBack

Which seems to work.

2 comments:

  1. Neither works for me

    ReplyDelete
  2. One strange thing is that ScriptManager.GetCurrent(Page).IsInAsyncPostBack seems to return true for controls inside an updatepanel, but still false for async page methods.

    ReplyDelete