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.

No comments:

Post a Comment