![](/img/trans.png)
[英]'Back' button to previous Modal Popup (Ajax Modal Popup Extender)
[英]formview with ajax modal popup extender
我已经尝试了几种方法,但似乎没有一种对我有用。 我有一个Formview,当用户进入编辑模式然后单击“更新”时,我希望显示一个模式弹出窗口,以便他们可以输入有关更改内容的注释。
这是我的代码
<ajaxToolkit:ModalPopupExtender ID="SubmitButton_ModalPopupExtender"
runat="server" OkControlID="EditNoteButton" PopupControlID="EditNotePanel"
BehaviorID="MPE" BackgroundCssClass="modalBackground"
TargetControlID="DummyButton">
</ajaxToolkit:ModalPopupExtender>
<asp:Panel ID="EditNotePanel" runat="server" CssClass="style105" Height="23px" style="display: none">
<asp:TextBox ID="EditNoteBox" runat="server" CssClass="style106" Height="68px" Width="223px">What Did You Change?</asp:TextBox> <br />
<asp:Button ID="EditNoteButton" runat="server" CssClass="style107" Height="29px" Text="Ok" Width="52px" CommandName="update" /> <br />
</asp:Panel>
C#
protected void ClientInformationForm_ItemCommand(Object sender, FormViewCommandEventArgs e)
{
//case statements
if (ClientInformationForm.CurrentMode == FormViewMode.Edit)
{
SubmitButton_ModalPopupExtender.TargetControlID = ((Button)ClientInformationForm.FindControl("SubmitButton")).UniqueID;
}
根据我的阅读,这应该可行。 我尝试通过clientclick上的javascript显示它。 我试图通过在itemcommand中调用modal.show()来显示它,但是没有一个显示它。 面板或弹出窗口在formview内部还是外部是否重要?
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack && Session["CurrentAccountId"] != null)
{
AddressTypeddl.DataBind();
ShippingAddressddl.DataBind();
AddressForm.DataBind();
}
if (ClientInformationForm.DataItemCount == 0)
{
ClientInformationForm.BackColor = Color.FromArgb(0xd9e2bf);
}
else
{
ClientInformationForm.BackColor = Color.White;
}
if (Session["CurrentAccountId"] == null)
{
NoteBox.Visible = false;
NewNoteButton.Visible = false;
NoteTypeddl.Visible = false;
NoteLabel.Visible = false;
NoteTypeLabel.Visible = false;
NewNoteLabel.Visible = false;
CreditCardView.Visible = false;
NewAccountButton.Visible = true;
AddressTypeddl.Visible = false;
AddressLabel.Visible = false;
AddressForm.Visible = false;
}
else
{
NoteBox.Visible = true;
NewNoteButton.Visible = true;
NoteTypeddl.Visible = true;
NoteLabel.Visible = true;
NoteTypeLabel.Visible = true;
NewNoteLabel.Visible = true;
CreditCardView.Visible = true;
NewAccountButton.Visible = false;
AddressTypeddl.Visible = true;
AddressLabel.Visible = true;
AddressForm.Visible = true;
}
}
所以我才意识到,如果我希望人们继续发贴,我需要编辑我的原始贴子,而不仅仅是添加便笺,因此希望对您有所帮助。 无论如何,我仍然无法使它正常工作,而且我不知道是什么原因导致弹出窗口无法启动?
如果要在用户进行编辑后弹出模态,我将不使用ItemCommand事件。
我没有使用FormViews,主要是GridViews。 但我假设原理基本相同。
您是否尝试在ItemUpdated事件中显示模式?
我以前没有尝试过,但是我想这样的事情可能会起作用:
protected void ClientInformationForm_ItemUpdated(Object sender, FormViewUpdatedEventArgs e)
{
//capture ID of the updated record, and perhaps store it in a HiddenField that's in the modal
SubmitButton_ModalPopupExtender.Show();
}
经过几天的反复试验,我终于弄清了为什么它不起作用。 它下降到虚拟按钮。 我将visible设置为false以隐藏按钮,并且由于某些原因而无法正常工作。 一旦我将其更改为style = display:none; 它开火了。 很奇怪没有抛出任何错误,只是从未弹出过。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.