开发者

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

开发者 https://www.devze.com 2022-12-16 14:58 出处:网络
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

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 w开发者_运维知识库ay 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.


Even though the controls are hidden, they are still created and they still go through the web forms page lifecycle. The ModalPopup just displays the already bound and rendered controls.

I would suggest using a javascript ajax method (create an XmlHttp object -- this is very easy to do with jquery). Your controls will be rendered and go through the page lifecycle at that time. Your binding will occur with the CslaDataSource OnSelectObject method.

0

精彩评论

暂无评论...
验证码 换一张
取 消