ASP.Net Ajax: make sure you check for IsAsync!

I am experimenting with a couple of Ajax controls from the AjaxControlsToolkit. I have read quite a couple of articles about them, but you never know when to apply that knowledge you acquired by browsing around.

Well, today I hit a problem using a CalendarExtender in a FormView on an UpdatePanel:

Selecting the Edit mode of the FormView always raised a Javascript exception stating a Javascript syntax error, and a .js file not being able to be loaded.

After googling around and finding that I am the only one on the planet that experiences that problem, I remembered an article about Ajax traps and handling of asynchronous events.

It turned out that the page containing the UpdatePanel always triggered my session check, which would redirect to an error message in case the session had timed out.
The solution was to use a

if (!IsAsync)

every now and then, and it seems that did it😉

3 Responses to ASP.Net Ajax: make sure you check for IsAsync!

  1. Daniel Modig says:

    Hi there!

    I’ve encountered the exact same problem in my development. Since i really can’t figure this one out i would be really thankful if u could explain a bit more in how to overcome this problem, i don’t understand where to put the check for async..

    Thanks in advance!

  2. devio says:


    in my code, the session check I mentioned always takes place in the Page_Load event , and I made sure that the session check (i.e. is the user logged in and allowed to view the page) is not performed if IsAsync is true.

    Depending on the architecture of your code, you have to find the places where your code breaks if called asynchronously; setting a breakpoint in lines where the Session object is accessed seems a good starting point.

  3. Daniel Modig says:

    Hi again!

    I solved that problem now, used your tip and it work’s just fine, but ofcourse I’ve encountered another problem.
    Maybe it’s a longshot, but I thought that you might know something about this one:

    Inside an UpdatePanel I have a Formview which is programatically databound to display the first result in a dataset. I use a repeater outside the updatepanel to trigg the updatepanel to update and so far so good.

    In the formview I have several textboxes and when i fire a submit-button it calls a sub for saving my data to a database, but here is my problem: It won’t receive any of the data, whether I’m using Ctype(formview1.findcontrol(“myControl”)) or just the findcontrol-method..

    You might think of me as an idiot, and as I said it’s a longshot, but it might be worth it.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: