Somnath Kharat
Somnath Kharat

Reputation: 3610

To close the ModalPopupExtender which contains .ascx(user control)

I have a ModalPopupExtender which contains user control(.ascx).
I want to close the popup by using button click which is in user control(.ascx).
I want to do it on client side(Jquery,Javascript)

ModalPopupExtender:

<asp:HiddenField ID="hidPopup" runat="server" />
    <ajaxToolkit:ModalPopupExtender ID="Surface1ModulePopup" PopupControlID="divPopup"
     runat="server" TargetControlID="hidPopup" CancelControlID="btnimageclose" >
    </ajaxtoolkit:ModalPopupExtender>
    <div id="divPopup" class="over_line" style="visibility:hidden;">
        <div class="TxConsultPopUp_Window" style="background-color: #f2fbff; height: 235px;
            width: 156px; border: 1 px solid #4490d2; margin-left: -140px; margin-top: 0px;">
            <div class="forg_head">
                <div class="head_txt" style="width: 119px; text-align: left;">
                    Surface Selections</div>
                <div class="close_but" style=" width:26px;">
                    <asp:ImageButton ID="btnimageclose" runat="server"  ImageUrl="images/close.png" OnClientClick="javascript:CloseWin();return false;" />
                </div>
            </div>
            <asp:Panel ID="panel1" runat="server">
              <UC1:Surface id="Surf1Surface" runat="server">
           </UC1:Surface>
           </asp:Panel>
         </div>
     </div>

To open it i have used this:

var modalPopupBehaviorCtrl = $find('<%=Surface1ModulePopup.ClientID %>');
modalPopupBehaviorCtrl.show();
var ScheduledTreatments = document.getElementById("divPopup");
ScheduledTreatments.style.visibility = "visible";

PLEASE HELP ME WAITING FOR ANSWER FROM 1 DAY.STACKFLOW EXPERTS PLEASE ANSWER IT

Upvotes: 0

Views: 1967

Answers (1)

mark.oliver.asp.newbie
mark.oliver.asp.newbie

Reputation: 644

My first ever answer on here, so fingers crossed it works for you.

The ID used in the CancelControlID is in effect a subset of the whole path (XPath) of the control, so if you extend the ID to include the usercontrol name as well, and force it to have a static name, then you can reference it.

Our ASP naming convention in use separates it by a dollar sign ($), so you can change CancelControlID="btnimageclose" to CancelControlID=Surf1Surface$nameofyourbutton. ( I believe you can change what is used, so you will need to check your rendered content for which you use.)

You will also need to set the ClientIDMode=Static property on the button in the usercontrol

This works for me, with this code:

Definition of the ModalPopupExtender:

<ajaxToolkit:ModalPopupExtender ID="showReferences" runat="server" 
CancelControlID="ucShowACarersFeedback$CloseWindow" TargetControlID="reviewsButton" 
PopupControlID="referencesPanel" BackgroundCssClass="ModalPopupBG">

The panel that it pops up

<asp:Panel CssClass="popupConfirmation" ID="referencesPanel" Style="display: none;"
    runat="server">
   <uc:ShowACarersFeedback runat="server" ID="ucShowACarersFeedback" />
</asp:Panel>

The button in the control usShowACarersFeedback

<asp:Button ID="CloseWindow" runat="server" Text="Close Feedback window" ClientIDMode=Static />

Upvotes: 1

Related Questions