1

Closed

UpdatePanelAnimationExtender - null reference at AsyncPostBackTrigger cast

description

Hi,

When I try to use UpdatePanelAnimationExtender I'm always getting the error Object reference not set to an instance of an object.
My project worked fine until I updated Ajax Control Toolkit to version 15.1.4

Thank you,

file attachments

Closed Mar 10, 2016 at 4:08 PM by MikhailTymchukDX
AJAX Control Toolkit was moved to GitHub: https://github.com/DevExpress/AjaxControlToolkit
The fix for this issue is available with the v16.1 release: https://github.com/DevExpress/AjaxControlToolkit/releases/tag/16.1.0

comments

MikhailTymchukDX wrote Nov 12, 2015 at 12:04 PM

I have tried to reproduce the issue you are talking about but everything operates correctly on my side.
Would you please provide a sample project showing the problem so that I can research it and find the cause?

etsmes wrote Nov 12, 2015 at 12:38 PM

Hi Mikhail,

I attach one aspx file of my project that throws "Object reference not set to an instance of an object" at AjaxControlToolkit.UpdatePanelAnimationExtender.OnPreRender.

All pages are now failing but working fine with AjaxControlToolkit version 09/2011.
If I create a new page with an UpdatePanel and an UpdatePanelAnimationExtender it works.

Thanks a lot for your attention,

MikhailTymchukDX wrote Nov 12, 2015 at 1:52 PM

I cannot build a project based on the page markup you provided because of many dependencies (like ObjectDataSource).
Would you please narrow down your example by deleting everything that does not influence AJAX Control Toolkit behavior and your page? As a result, we will have a project with a single page and all dependencies to run it, but it still produces an AJAX Control Toolkit related error.

etsmes wrote Nov 13, 2015 at 8:26 AM

Hi,

I've found what causes the exception but I don't know why...
If I remove the following code, the page renders with no errors (obviously buttons stop working)
<Triggers>
<asp:PostBackTrigger ControlID="btn_Imprimir" />
<asp:PostBackTrigger ControlID="btn_ImprimirExcel" />
</Triggers>

I don't know how to solve it.
Thanks

MikhailTymchukDX wrote Nov 13, 2015 at 8:49 AM

This indicates some problems with the UpdatePanelAnimationExtender.AnimationTarget property.
However, I cannot say something more specific, because I haven't seen your application code.
Please provide a sample project showing the problem so that I can research it and find the cause.

etsmes wrote Nov 13, 2015 at 10:16 AM

https://dl.dropboxusercontent.com/u/5073388/Test2.zip

WebForm1.aspx execution throws the exception

Thanks a lot

MikhailTymchukDX wrote Nov 13, 2015 at 12:14 PM

I found the factor that caused this error: your UpdatePanel has asp:PostBackTrigger, but UpdatePanelAnimationExtender needs asp:AsyncPostBackTrigger.
You can see here that UpdatePanelAnimationExtender casts every trigger to AsyncPostBackTrigger in the OnPreRender method, so using AsyncPostBackTrigger is the only way of resolving this problem.

etsmes wrote Nov 13, 2015 at 12:49 PM

Hi Mikhail,

But I need that an specific button inside the UpdatePanel not trigger the UpdatePanelAnimationExtender. How can I do that?

Thanks,

MikhailTymchukDX wrote Nov 13, 2015 at 1:27 PM

Do not refer to this button in the triggers section. This will keep this button working (you will receive a server event when clicking this button), but the animation will not run.

etsmes wrote Nov 16, 2015 at 1:01 PM

Hi Mikhail,

This button is supposed to print a Crystal Report. If I remove it from the trigger section, when the user clicks it throws an Exception (Sys.WebForms.PageRequestManagerParserErrorException) and is not able to print the report.

Thanks,
Josep

etsmes wrote Nov 17, 2015 at 11:10 AM

Hi Mikhail,

Using RegisterPostBackControl on code behind it works.

Regards

MikhailTymchukDX wrote Nov 17, 2015 at 11:55 AM

Hi Josep,

I'm happy to hear that you managed to work around this issue. However, UpdatePanelAnimatonExtender's OnPreRender method behavior is incorrect in general.

So, I changed it to allow UpdatePanel to have PostBackTriggers along with AyncPostBackTriggers, but UpdatePanelAnimatonExtender will not react to PostBackTriggers.
This keeps your PostBackTrigger button working, while UpdatePanelAnimatonExtender animation will be triggered as usual by AyncPostBackTrigger elements.

You can get this change with the latest source code: https://ajaxcontroltoolkit.codeplex.com/SourceControl/latest
Please let me know if this change has helped you print the Crystal Report without modifying code behind.

etsmes wrote Nov 17, 2015 at 12:40 PM

Hi Mikhail,

It works like a charm! Thank you!

Just one more question:
I've downloaded the source code and compiled it in order to use the AjaxControlToolkit.dll, but I've checked that the version is 15.1.2 (not 15.1.4).
Shall I use it or it is a better to wait for the next Ajax Control Toolkit release?

Regards,
Josep

MikhailTymchukDX wrote Nov 17, 2015 at 1:27 PM

No, this version is a placeholder. We are putting the right version every release into assemblies, the NuGet package and installer, but this workflow does not affect the source code, so this version string remains untouched.

etsmes wrote Nov 18, 2015 at 11:36 AM

OK
Thank you

I will wait until the next release.

MikhailTymchukDX wrote Feb 2, 2016 at 12:44 PM

The title was edited as this issue is included in What's new list for the v16.1 release.