ModalPopupExtender Sys.ArgumentNullException Error

Are you are seeing this javascript error when you try to run a page with a ModalPopupExtender in it?

Error: Sys.ArgumentNullException: Value cannot be null.
Parameter name: element

Then the fix is probably pretty simple - you have put incorrect ID's in either the OkControlID or CancelControlID attributes.

You don't have to specify the OkControlID or CancelControlID's to use the ModalPopupExtender but if you do and you later rename the control or you simply mistype when setting it up the compiler will not catch this.

The error message could be more helpful but hopefully you will have found this article in your favourite search engine without much trouble!

Here is the official documentation and demo page for this control:

18 comments :

Anonymous said...

thx m8

unknown said...

Thanx buddy....it works....i rechecked both ids of ok and cancel button..a littlebit mistake was there.......Thanx..

Anonymous said...

Excellent!!! Thank you sooooo much!!!! You have made my day!!!

Abel said...

Thankssss a lotttt

hasu said...

Thanks, it worked!

Anonymous said...

thanx a lot brother for this info..it's very usefull !!!!

Predator said...

Man thanks! Merci beaucoup! I copied and pasted big chunks of code from one page to another one. What happened is in the new page, some controls with same name already existed, so Visual Studio stealthily renames my controls (some button) so the modalpopup extender exploded :) I just renamed the attribute with the newly attributed name of my button and yes it works like a charm. May I share this info everywhere but also give the link to your post because you deserve the credit obviously!

Anonymous said...

Thanks,, saved me in the right time.

Dimitris said...

great advice!! you saved me so many time.... thnks

Anonymous said...

great advice... thanks !!

Anonymous said...

Many thanks.

Anonymous said...

Life saver... exactly what I had; using modalpopupextender.

In my case, I actually was missing a line for an element that needed to be there.

Problem solved.

Thanks!

Anonymous said...

This seems to be the only source of this little gem on the web.

Worked a treat!
JG

Abhijit P said...

Thanks. Just the right answer. Saved me a ton of time.

chandan said...

Hey Dude...

Awesome find...just found the same mistake..You saved lot of time of mine... :)
Thanks

Vijaya Kumar K S said...


Thanks! Great fix, this solved my problem and saved my project

Anonymous said...

Thanks changing the correct canclecontrolid solved my error.

Anonymous said...

Or, if you set Visible = False on the control specified in the CancelControlID, you'll also get this error. But this post helped out a lot! Thanks.