tags:

views:

28

answers:

2

Hello,

I am trying to get a popup after saving some data into the database. When using the ConfirmButtonExtender and ModalPopupextender, it asks for TargetControlID. So i have given TargetcontrolID as Submit button. So whenever the submit button is clicked, it shows the popup first saying "your password is successfully saved". After you close the popup, it saves information in the database. This shouldn't be the case. It has to first save the information in database and if it successfully saves the password, popup should be shown. What do you think i should change? Please help..

<cc1:ConfirmButtonExtender DisplayModalPopupID="ModalPopupExtendersave" ID="ConfirmButtonExtendersave"
    runat="server" TargetControlID="imgbtnSubmit">
</cc1:ConfirmButtonExtender>
<cc1:ModalPopupExtender ID="ModalPopupExtendersave" runat="server" TargetControlID="imgbtnSubmit" BackgroundCssClass="modalBackground"
    OkControlID="btnOK" PopupControlID="pnlPopup" >
</cc1:ModalPopupExtender>




protected void imgbtnSubmit_Click(object sender, ImageClickEventArgs e)
{
    if (txtpassword1.Text != "" && txtpassword2.Text != "" && txtpassword1.Text == txtpassword2.Text)
    {
        Savepassword();

        if (Savepassword())
        {
            ModalPopupExtendersave.Show();
            pnlPopup.Visible = true;
        }
        else
        {
            lblerror.Text = "Error in saving password";
        }
    }

}

Thank you all!!

+2  A: 

Hi Ram:

Add LinkButton or Button Control with visible equal false and set it as TargetControlID , then in code behind call Show method for the ModalPopupExtender Control.

DEVMBM
@Ram: It looks like you can also get rid of the ConfirmButtonExtender. In this case it isn't doing anything.
kevev22
Fantastic! Thanks so much guys! :)
Ram
+1  A: 

I agree with DEVMBM - here is an example:

<script runat="server">
    protected void btnShowModal_Click(object sender, EventArgs e)
    {
        // do stuff here - e.g. save password to database

        // show modal popup
        mpeModalDemo.Show();
    }
</script>

<asp:ImageButton
    ID="btnShowModal"
    OnClick="btnShowModal_Click"
    CausesValidation="false"
    runat="server" />

<asp:UpdatePanel ID="updModalDemo" UpdateMode="Conditional" runat="server">
<ContentTemplate>

    <asp:Button
        ID="btnFakeTarget"
        CausesValidation="False"
        Style="display: none"
        runat="server" />

    <ajax:ModalPopupExtender
        ID="mpeModalDemo"
        BackgroundCssClass="modalBackground"
        PopupControlID="pnlModalDemo"                    
        TargetControlID="btnFakeTarget"
        PopupDragHandleControlID="pnlModalDemo"
        runat="server" />

    <asp:Panel
        ID="pnlModalDemo"
        style="display:none;"
        runat="server">

        <style type="text/css">
            .modalBackground {
                background-color: #000000;
                filter: alpha(opacity=40);
                opacity: 0.7;
            }
        </style>

        <!-- modal popup content here -->

    </asp:Panel>

</ContentTemplate>
</asp:UpdatePanel>
Jonathan