I am using a ModalPopupExtender that displays an UpdatePanel that contains a custom control. Whenever someone clicks on the button to show my ModalPopupExtender, after you close the Modal window, the first time you click on anything in the web page it doesn't
work. You have to click a second time to get any links, buttons, etc to work. It's almost like the modal popup is disabling the page behind it and the page doesn't have focus until you click on something. I tried just clicking anywhere in the page and that
doesn't work. You have to click on a control that does something. I confirmed that no matter how many times I load my page and how I load it, it only occurs right after showing the ModalPopup.
Example: I click on the button on my form called 'Open Modal'. It opens the modal window. I click on the 'Cancel' button inside the modal window and it closes. I select a link inside the page and it doesn't do anything. I click that same link a second
time and it fires the click event.
Please mark the replies as answers if they help or unmark if not.
If you have any feedback about my replies, please contact msdnmg@microsoft.com.
Microsoft One Code Framework
I'm having the same problem, but it's with a calendar inside an update panel. When I hide de modal popup, I have to click twice on a date to have the selected date changed event fired.
I think this issue had multiple solutions based on which type of popup you are using; either modal or just a normal popup control. I think to resolve this issue, I set the OnClientClick event on all controls within my popups to...
return false;
I also set the AutoPostBack = "False"
Although I don't think setting these two properties on each of the sub controls is the final solution, I think it helped, because it won't allow the control to postback on the click events, and then the Popup or ModalPopup control extender takes over from
there and posts back using javascript code in the background as necessary. I think the main solution is using the OkControlID and CancelControlID, which I go into more at the bottom of this post.
Something that isn't very intuitive is the ModalPopupExtender's properties. I always get confused between the TargetControlID and the PopupControlID. I get them backwards. Another thing to note is to make sure that you have your BehaviorID set in your
popup controls!! I have found that AJAX really needs those to function properly.
Here is another neat feature that I incorporated into my popups. You can dynamically set the closing button to your popup by doing the following. This code sets the btnClose button's click event to find the ModalPopupExtender named mpeEmail by using its
BehaviorID, then calling hidePopup() and then return false; in javascript so the button click event doesn't fire and page doesn't postback accidentally. It's pretty cool.
Something that is also nice to note here is that there is a special property in the ModalPopupControl that is called CancelControlID. It basically does the same thing my code above does; it sets whatever control you want as the closing control of the popup.
It's too bad the normal Popup control extender doesn't have it. That's why I use the code above. Here is an example of one of my Modal Popups using the CancelControlID, which happens to be an image button that looks like a red x.
There is yet another special property not available in the ModalPopupControl called the OkControlID. I don't recall exactly how it us used behind the scenes, but it doesn't do what I thought it would do. I thought it would postback the modal popup, but
it doesn't. It just closes the popup. I seem to recall that if I hit the Ok control, then it saved my data in the modal popup, but if I hit the cancel control, then it didn't save my data in the modal popup fields. You will have to do some research on that
one.
I think setting those control ID's was what helped me the most. Without setting these values and using those buttons to close the modal popup, it left the modal popup in limbo until I tried activating another control on the page. Hopefully some of this
helps. Good luck!
What I am having to do for this, is on whichever command you are using that actuall closes the popup, simulate a click onto another control, the click never fires but does mean when you click the target again the popup fires again.
I am having a page on which a gridview is there, the grid view is having column of checkboxes. when i click on one of the check boxes a popup appears if criteria does not satisfies, popup shows a question "do u want to uncheck the check box, bcoz
criteria is not satisfied" with two buttons yes and no. When I click on yes, no functionality is needed since the checkbox is already clicked but when i click on no the checkbox should be unchecked.
The problem i was facing is i had to click the NO button twice to get it work and uncheck the check box.
I have modal popup in a update panel, which i kept in same panel in which my grid view is situated. but the problem was depending on some condition i was hiding the grid view, to do that i was hiding the whole panel in which the grid view and update panel
was there.
We just have to keep the update panel out of any other panel which is going to hide some or other time. since i am hiding the panel on some conditions. and update panel should not be hidden.
Simple thing to do first, is not make sure all your ModalPopupExtenders TargetControlID and PopupControlID controls are accounted for on the page. I encountered this after removing some of my controls off a page and ended up having to click everything twice.
The Java Error console complains about a value that can not be null, so I figured something was looking for something and started check all the Controls I was referencing and there was one missing. When I corrected, the clicking twice behaviour went away!
jon.ebersole
Member
41 Points
47 Posts
ModalPopupExtender and Update Panel - Have to click twice after hiding ModalPopupExtender
Oct 12, 2007 09:38 PM|LINK
I am using a ModalPopupExtender that displays an UpdatePanel that contains a custom control. Whenever someone clicks on the button to show my ModalPopupExtender, after you close the Modal window, the first time you click on anything in the web page it doesn't work. You have to click a second time to get any links, buttons, etc to work. It's almost like the modal popup is disabling the page behind it and the page doesn't have focus until you click on something. I tried just clicking anywhere in the page and that doesn't work. You have to click on a control that does something. I confirmed that no matter how many times I load my page and how I load it, it only occurs right after showing the ModalPopup.
Example: I click on the button on my form called 'Open Modal'. It opens the modal window. I click on the 'Cancel' button inside the modal window and it closes. I select a link inside the page and it doesn't do anything. I click that same link a second time and it fires the click event.
I am using AjaxControlToolkit 1.0.10920
Any help would be greatly appreciated. Thanks!
Jon Ebersole
Jonathan She...
All-Star
31269 Points
3445 Posts
Re: ModalPopupExtender and Update Panel - Have to click twice after hiding ModalPopupExtender
Oct 18, 2007 07:23 AM|LINK
Hi Jon.ebersole,
Would you please share a simple repro?
Best regards,
Jonathan
If you have any feedback about my replies, please contact msdnmg@microsoft.com.
Microsoft One Code Framework
jon.ebersole
Member
41 Points
47 Posts
Re: ModalPopupExtender and Update Panel - Have to click twice after hiding ModalPopupExtender
Oct 19, 2007 07:06 PM|LINK
Did you get my private email Jonathan?
Jon Ebersole
gonzzas
Member
103 Points
32 Posts
Re: ModalPopupExtender and Update Panel - Have to click twice after hiding ModalPopupExtender
Feb 25, 2008 09:54 PM|LINK
I'm having the same problem, but it's with a calendar inside an update panel. When I hide de modal popup, I have to click twice on a date to have the selected date changed event fired.
Any solutions on this?
jon.ebersole
Member
41 Points
47 Posts
Re: ModalPopupExtender and Update Panel - Have to click twice after hiding ModalPopupExtender
Mar 01, 2008 05:04 PM|LINK
I think this issue had multiple solutions based on which type of popup you are using; either modal or just a normal popup control. I think to resolve this issue, I set the OnClientClick event on all controls within my popups to...
return false;
I also set the AutoPostBack = "False"
Although I don't think setting these two properties on each of the sub controls is the final solution, I think it helped, because it won't allow the control to postback on the click events, and then the Popup or ModalPopup control extender takes over from there and posts back using javascript code in the background as necessary. I think the main solution is using the OkControlID and CancelControlID, which I go into more at the bottom of this post.
Something that isn't very intuitive is the ModalPopupExtender's properties. I always get confused between the TargetControlID and the PopupControlID. I get them backwards. Another thing to note is to make sure that you have your BehaviorID set in your popup controls!! I have found that AJAX really needs those to function properly.
Here is another neat feature that I incorporated into my popups. You can dynamically set the closing button to your popup by doing the following. This code sets the btnClose button's click event to find the ModalPopupExtender named mpeEmail by using its BehaviorID, then calling hidePopup() and then return false; in javascript so the button click event doesn't fire and page doesn't postback accidentally. It's pretty cool.
btnClose.Attributes.Add("onclick", "$find('" & mpeEmail.BehaviorID & "').hidePopup();return false;")
Something that is also nice to note here is that there is a special property in the ModalPopupControl that is called CancelControlID. It basically does the same thing my code above does; it sets whatever control you want as the closing control of the popup. It's too bad the normal Popup control extender doesn't have it. That's why I use the code above. Here is an example of one of my Modal Popups using the CancelControlID, which happens to be an image button that looks like a red x.
There is yet another special property not available in the ModalPopupControl called the OkControlID. I don't recall exactly how it us used behind the scenes, but it doesn't do what I thought it would do. I thought it would postback the modal popup, but it doesn't. It just closes the popup. I seem to recall that if I hit the Ok control, then it saved my data in the modal popup, but if I hit the cancel control, then it didn't save my data in the modal popup fields. You will have to do some research on that one.
I think setting those control ID's was what helped me the most. Without setting these values and using those buttons to close the modal popup, it left the modal popup in limbo until I tried activating another control on the page. Hopefully some of this helps. Good luck!
Jon Ebersole
hermer
Member
8 Points
4 Posts
Re: ModalPopupExtender and Update Panel - Have to click twice after hiding ModalPopupExtender
Oct 17, 2008 03:56 PM|LINK
What I am having to do for this, is on whichever command you are using that actuall closes the popup, simulate a click onto another control, the click never fires but does mean when you click the target again the popup fires again.
document.getElementById('txtSashTxtBack').click();
skiah
Member
85 Points
48 Posts
Re: ModalPopupExtender and Update Panel - Have to click twice after hiding ModalPopupExtender
Mar 31, 2010 05:37 PM|LINK
I ran in to this and simply added the following to the image button that I was using to close the panel.
OnClientClick="return false;"
Shaikh Sadaf
Member
2 Points
1 Post
Re: ModalPopupExtender and Update Panel - Have to click twice after hiding ModalPopupExtender
Sep 14, 2010 11:15 AM|LINK
Hi there,
Always keep the update panel out of other panels in which u r going to call (Modal popup) the update panel.
-----------------------------------------------------------------------------------------------------------
My Problem:
I am having a page on which a gridview is there, the grid view is having column of checkboxes. when i click on one of the check boxes a popup appears if criteria does not satisfies, popup shows a question "do u want to uncheck the check box, bcoz criteria is not satisfied" with two buttons yes and no. When I click on yes, no functionality is needed since the checkbox is already clicked but when i click on no the checkbox should be unchecked.
The problem i was facing is i had to click the NO button twice to get it work and uncheck the check box.
----------------------------------------------------------------------------------------------------------------
SOlution to the problem:
I have modal popup in a update panel, which i kept in same panel in which my grid view is situated. but the problem was depending on some condition i was hiding the grid view, to do that i was hiding the whole panel in which the grid view and update panel was there.
------------------------------------------------------------------------------------------------------------------
Eg:
<asp:panel id="Mypanel">
<asp:gridview>
;
</asp:gridview>
<asp:UpdatePanel ID="upl2" runat="server"><ContentTemplate> <asp:LinkButton ID="lkbtnTemp2" runat="server" Style="display: none"></asp:LinkButton>
<cc1:ModalPopupExtender>< /cc1:ModalPopupExtender>
</UpdatePanel>
</Panel>
We just have to keep the update panel out of any other panel which is going to hide some or other time. since i am hiding the panel on some conditions. and update panel should not be hidden.
<asp:panel id="Mypanel">
<asp:gridview>
;
</asp:gridview>
</Panel>
<asp:UpdatePanel ID="upl2" runat="server"><ContentTemplate> <asp:LinkButton ID="lkbtnTemp2" runat="server" Style="display: none"></asp:LinkButton>
<cc1:ModalPopupExtender>< /cc1:ModalPopupExtender>
</UpdatePanel>
daniefvh
Member
2 Points
1 Post
Re: ModalPopupExtender and Update Panel - Have to click twice after hiding ModalPopupExtender
Nov 15, 2010 07:36 AM|LINK
Simple thing to do first, is not make sure all your ModalPopupExtenders TargetControlID and PopupControlID controls are accounted for on the page. I encountered this after removing some of my controls off a page and ended up having to click everything twice. The Java Error console complains about a value that can not be null, so I figured something was looking for something and started check all the Controls I was referencing and there was one missing. When I corrected, the clicking twice behaviour went away!
angelxnyc
Member
22 Points
21 Posts
Re: ModalPopupExtender and Update Panel - Have to click twice after hiding ModalPopupExtender
Mar 16, 2012 04:45 PM|LINK
OnClientClick="return false;"
I set that in the aspx page on the cancel button properties, while also having the modal extender setting that cancel button as the cancel control id.
It worked for me thanks.