我想在将一些数据保存到数据库后尝试弹出窗口。使用ConfirmButtonExtender和ModalPopupextender时,它会询问TargetControlID。所以我已经将TargetcontrolID作为提交按钮。因此,无论何时单击提交按钮,它都会首先显示弹出窗口“您的密码已成功保存”。关闭弹出窗口后,它会将信息保存在数据库中。情况并非如此。它必须首先将信息保存在数据库中,如果成功保存密码,则应显示弹出窗口。你认为我应该改变什么?请帮忙..
<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";
}
}
}
谢谢大家!!
答案 0 :(得分:2)
添加可见等于false的LinkButton或Button Control并将其设置为TargetControlID,然后在代码后面调用ModalPopupExtender控件的Show方法。
答案 1 :(得分:1)
我同意DEVMBM - 这是一个例子:
<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>