Thursday, March 03, 2011

ASP.NET & AJAX: “Object required” Script error while using ModalPopupExtender

Loading an ASP.NET Webpage containing ModalPopupExtender you may encounter following error:

Webpage error details

User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0; SLCC1; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729)
Timestamp: Thu, 3 Mar 2011 07:21:58 UTC


Message: Object required
Line: 106
Char: 13
Code: 0
URI:
http://localhost:49461/ScriptResource.axd?d=dVTmaeP-mJEQBF1x5WPACI57lI3BdxWWqqcjOSvk5IFYlzy3XmoJ3-mETMUX_E93dUXCirqabEt7Y5F8nk9OJF0v1sSq6MFJL4n1ystjZ74KXzsw7JAw7fRseSEZ165rrnTm4dOfgdUE7UZpQUpfBqdlctB5nzYxeqQR46Jg_TR_hyK50&t=ffffffffa4fab0f1

image

Start debugger, and you will learn more:

image

this._popupElement = $get(this._PopupControlID);
if (this._DropShadow) {
this._foregroundElement = document.createElement('div');
this._foregroundElement.id = this.get_id() + '_foregroundElement';
this._popupElement.parentNode.appendChild(this._foregroundElement);
this._foregroundElement.appendChild(this._popupElement);
}
else {
this._foregroundElement = this._popupElement;
}


The cause of this error is most likely the Panel used as TargetControl for ModulPopupExtender. Check if this Panel not set accidentally to



Visible="false"


In this case ASP.NET doesn’t render this panel at all, and the _PopupControlID property of the popup extender on the client side points to non existent object.


Check the Visible attribute of the popup panel, reset it to visible and enjoy!

2 comments:

Anonymous said...

Hi,

Thanks for this post, this fixed my errors..

Anonymous said...

Hi,

Thanks a lot, this fixed my problem as well.