Monday, March 26, 2012

Modal Popup Extender with multiple TargetControlID?

Hello, I'm new to the toolkit and I'm looking for ideas to accomplish a somewhat trivial goal.

What I want is to show a panel in modal form base on the item chosen on a list.

Imagine a list of employees and you want that when the user clicks on one of them a modal window comes up and allows the user to edit the chosen employee's data.

the problem is that the ModalPopupExtender has room just for a single TargetControlID.

Does anyone know a way to accomplish this?


TIA

Yes I beleive you are correct in that the ModalPopupExtender allows only one TargetControlID, however you can have multiple ModalPopupExtenders on a page if you need multiple (different) Panels for input.

If you need only one Modal and want to show it from many different events you can create a button which will be shown as visible inline but on Page Load set the visibility to none and set it as your TargetControlID. Then in any events you need the modal simply call ModalPopupExtender.show() method with 'ModalPopupExtender' being the ID of your extender. The reason I say to leave the visibility set to true inline is I recently read a post where the Events were not getting attached at run time in some cases unless they were set to visible at compile time. If you take a look at the Sample code for the toolkit they have an example of this scenario. Also keep in mind you might want to call the hide() method on the ModalPopupExtender when your finished with Input as some never get disposed and might cause problems next time you try to show one.

Hope this helps...

No comments:

Post a Comment