带有条件的单个按钮上的两个弹出窗口

时间:2010-11-23 18:48:04

标签: c# javascript asp.net ajax

我需要一个应该用javascript函数决定的弹出窗口。当我使用以下功能时,我没有弹出窗口。我觉得在某个地方犯了一个错误。有人能指出它是什么吗?

保存按钮调用javascript函数

<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" />                             

第二个是

<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" />     

2 个答案:

答案 0 :(得分:1)

if(loccount = "1")

看起来我们的等号队长有问题。 = != ==

答案 1 :(得分:0)

您实际上想要显示ModalPopupExtender的行为,而不是扩展器本身。尝试向每个ModalPopupExtender添加BehaviorID属性,然后使用以下JQuery代码:

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