challengeAccepted
challengeAccepted

Reputation: 7610

Two popups on a single button with a condition

I was needing a popup that should be decided with a javascript function. I do not get a popup when i was using the below function. I think am doing a mistake somewhere. Could someone point out what it is?

The save button calls the javascript function

<asp:ImageButton ID="btnSave" runat="server" CausesValidation="true" OnClientClick="isPageValid();return false;" ImageUrl="~/images/green-save.gif" 
                        OnClick="btnSave_Click" TabIndex="22" ValidationGroup="groupProfile" /></td>

function isPageValid()
{

var validated = Page_ClientValidate('groupProfile');
var loccount = document.getElementById('txthiddenloccount').value;

if(validated)
{
    if(loccount = "1")
    {
       var mdlPopup = $find('<%= ModalPopupExtendersavechanges.ClientID %>');
    } 
    else
    {
        var mdlPopup = $find('<%= ModalPopupExtenderMerchantUpdate.ClientID %>');
    }
    if(mdlPopup)
    {
       mdlPopup.show();           
    }
}
}


 <cc1:ConfirmButtonExtender DisplayModalPopupID="ModalPopupExtenderMerchantUpdate" ID="ConfirmButtonExtenderMerchantUpdate"
    OnClientCancel="ManageCancel()" runat="server" TargetControlID="btnHidden">
</cc1:ConfirmButtonExtender>
<cc1:ModalPopupExtender ID="ModalPopupExtenderMerchantUpdate" runat="server" BackgroundCssClass="modalBackground"
     CancelControlID="btnCancel" PopupControlID="pnlPopupMerchantUpdate" TargetControlID="btnHidden">
</cc1:ModalPopupExtender>

                        <asp:Button ID="btnYesMerchant"  Text ="Yes" runat="server" class="popupButton" causesvalidation="true" OnClientClick="$find('mdlpop').hide(); return true;" onclick="btnYessave_Click"/> 
                        <asp:Button ID = "btnNoMerchant" Text ="No" runat ="server" class="popupButton" causesvalidation="true" OnClientClick="$find('mdlpop').hide(); return true;" onclick="btnNosave_Click"/>
                       <asp:Button Id="btnCancel" Text ="Cancel" runat="server" class="popupButton" />                             

And the second is

<cc1:ConfirmButtonExtender DisplayModalPopupID="ModalPopupExtendersavechanges" ID="ConfirmButtonExtendersavechanges"
    OnClientCancel="ManageCancel()" runat="server" TargetControlID="btnHidden">
</cc1:ConfirmButtonExtender>
<cc1:ModalPopupExtender ID="ModalPopupExtendersavechanges" runat="server" BackgroundCssClass="modalBackground"
     CancelControlID="btnNo" OkControlID="btnYes" PopupControlID="pnlPopupsaveChanges" TargetControlID="btnHidden">
</cc1:ModalPopupExtender>

 <asp:Button ID="btnYes"  Text ="YES" runat="server" class="popupButton" causesvalidation="true" onclick="btnSave_Click"/> 
                        <asp:Button Id="btnNo" Text ="NO" runat="server" class="popupButton" />     

Upvotes: 1

Views: 746

Answers (2)

Matthew Jones
Matthew Jones

Reputation: 26190

You actually want to show the behavior of the ModalPopupExtender, not the extender itself. Try adding a BehaviorID attribute to each ModalPopupExtender, then use the following JQuery code:

    if(loccount == "1")
    {
       var mdlPopup = $find('ModalPopupExtenderSaveChangesBehaviorID');
    } 
    else
    {
        var mdlPopup = $find('ModalPopupExtenderMerchantUpdateBehaviorID');
    }
    if(mdlPopup)
    {
       mdlPopup.show();           
    }

Upvotes: 0

epascarello
epascarello

Reputation: 207527

if(loccount = "1")

Looks like we have a problem with the equals sign captain. = != ==

Upvotes: 1

Related Questions