CSLA, ASP.NET and AJAX ModalPopupExtender - how do I not load an object when the ModalPopup is not visible

CSLA, ASP.NET and AJAX ModalPopupExtender - how do I not load an object when the ModalPopup is not visible

Old forum URL: forums.lhotka.net/forums/t/8330.aspx


pkouzov posted on Monday, January 11, 2010

I am in the middle of an ASP.NET project where I am using the CSLA framework and the AJAX ModalPopupExtender control. I have used CSLA and the ModalPopupExtender in different projects before, but this is the first time I am using them together.

The way I want it to work is for the user to push a button, which will create an instance of an object and show the modal popup. The popup has controls bound to a CslaDataSource, based on the object that was just created.

Instead the way it actually works is it is loading the controls on the ModalPopup even when the popup is still hidden, e.g. during the initial page load. This generates an error, since the object to which the controls are binding does not exist yet, so it is not able to render the controls and the corresponding Javascript on the aspx page correctly. The error is: "Microsoft JScript runtime error: Sys.ArgumentNullException: Value cannot be null. Parameter name: element"

My current workaround is to create a dummy object upfront, just so there is something the controls on the popup can bind to initially. I then replace that object when the user pushes the button. I am wondering if there is a simpler way with less overhead that I may be missing.

Copyright (c) Marimer LLC