Showing posts with label trivial. Show all posts
Showing posts with label trivial. Show all posts

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...

Wednesday, March 21, 2012

ModalPopup and auto-updating controls/server-side function calls

I'm having trouble searching for an answer for this and have been unable to find one, but this seems like a very trivial question, maybe I'm just too tired to be doing this right now.

I have a ModalPopup, and in it I have 5 textboxes(all with autopostback enabled) and two dropdownlists, also with autopostbacks. Now, what I want to have happen is when I change the dropdownlists, the values in the textboxes inside the ModalPopup will change, but I don't want the popup to close. Right now, the autopostbacks are working as they should, but the popup closes each time.

This is my ModalPopupExtender code:

<cc1:ModalPopupExtender ID="ModalPopupExtender1" runat="server"> <cc1:ModalPopupProperties TargetControlID="LinkButton1" PopupControlID="PanelEdit" BackgroundCssClass="modalBackground" DropShadow="true" CancelControlID="NoButton" OnCancelScript="onNo()"> </cc1:ModalPopupProperties> </cc1:ModalPopupExtender>

Now, one thing I thought of was the fact that there's no OkControlId defined, this is sort of a hack to get my Ok button to actually call the server side code for the Ok button, rather than just the javascript. If this is the problem, how do I define the OkControlId, and have it call the server-side code associated with the button?

I appreciate any help anyone can offer to my problem, and if you need any more code, let me know.

Hi,

I don't know the details of the ModalPopup, but did you try to wrap the ModalPopup content (5 textboxes + ddls) inside an UpdatePanel? Performing a partial postback should keep the popup visible (just guessing though).


I originally wrapped the panel containing my controls in an UpdatePanel, but that didn't work. I just now tried putting the actual ModalPopupExtender into the same UpdatePanel, but it had no effect, the popup still disappears when the autopostback is triggered.

Hi,

I mean, not wrapping the extended Panel, but the content of the ModalPopup (inside the Panel). Did you try that?


I just tried that, but to no avail. As far as I can tell, the behavior hasn't changed at all when I put the UpdatePanel around just the controls inside the panel.

This won't solve the issue

I had the same problem but in vain. Any postback from any element in the ModalPopup will close it


Did you find a workaround for it? Like, is there a way to disable postbacks from cosing the ModalPopup, then just do it inside the button that you want to close it?
This post suggests an easy way to re-display the ModalPopup on the server during the postback with the 60914 release.

After looking at the post, I see the new way to do it, but I am having a problem:

I'm running the following code in the page load event...

ModalPopupProperties popup = ModalPopupExtender1.GetTargetProperties(UpdatePanelEdit);
if (popup !=null)
popup.Show();// Or call popup.Hide();

My problem is, popup never gets assigned to anything except null...does this code have to be placed somewhere outside of the Page_Load?


The control passed to GetTargetProperties needs to be the one that's specified as the TargetControlID for the ModalPopupProperties.
Ok, I changed the control names and whatnot, and now the properties isn't null, but the .Show() doesn't actually do anything. I've stepped through the code, and it does execute the popup.Show(); but it doesn't have any effect. I removed the UpdatePanel I had, and just used a regular Panel control to contain the popup. The above code is in the Page_Load, does it need to occur before the actual page load?

I had a problem somewhat similar to this.

What happens on postback, is it rebinds the display:none style to the panel, hiding it.
In mine, I had a gridview and several buttons that would change the contents of. I ended up wrapping just the gridview in an update panel, and assigning each of the buttons to a trigger for the update.

Not sure if you can use this in your situation but I hope it helps.