Popup issue with TargetControlID
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". Afte开发者_Go百科r 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!!
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.
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: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">
<asp:UpdatePanel ID="updModalDemo" UpdateMode="Conditional" runat="server">
<ContentTemplate>
<style type="text/css">
.modalBackground {
background-color: #000000;
filter: alpha(opacity=40);
opacity: 0.7;
}
</style>
<!-- modal popup content here -->
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnShowModal" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
</asp:Panel>
精彩评论