C# 带有ajax模式弹出扩展程序的formview
我试过几种方法,但似乎都不适合我。我有一个formview,当用户进入编辑模式,然后单击“更新”时,我希望显示一个模式弹出窗口,以便他们可以键入一个关于他们所更改内容的注释 这是我的密码C# 带有ajax模式弹出扩展程序的formview,c#,asp.net,ajax,modalpopupextender,formview,C#,Asp.net,Ajax,Modalpopupextender,Formview,我试过几种方法,但似乎都不适合我。我有一个formview,当用户进入编辑模式,然后单击“更新”时,我希望显示一个模式弹出窗口,以便他们可以键入一个关于他们所更改内容的注释 这是我的密码 <ajaxToolkit:ModalPopupExtender ID="SubmitButton_ModalPopupExtender" runat="server" OkControlID="EditNoteButton" PopupControlID="EditNotePanel" Behav
<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>
从我所读到的来看,这应该行得通。我尝试过在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事件 我很少使用FormView,主要是GridView。但我假设这些原则基本上是一样的 您是否尝试过在ItemUpdate事件中显示模式 我以前从未尝试过,但我想这样做可能会奏效:
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;它烧得很好。奇怪的是,没有抛出错误,只是从来没有出现过 我也试过了。它执行该代码,但仍然只是返回到更新的formview,而不显示弹出窗口。出于某种原因,无论我做什么,我都无法显示弹出窗口。您在页面加载中是否做了任何会覆盖模式的操作?我发布了页面加载,但我认为这不会影响此操作。很抱歉,我整个周末都得了流感,没有早点发布。样式与asp控件属性不同。style=“display:none”与visible=“false”不同。呈现时查看HTML代码。
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();
}