2013-10-29 162 views
0

我已经尝试了这几种方式,他们都没有人似乎为我工作。我有一个formview,当用户进入编辑模式,然后点击更新,我想要一个模式弹出窗口显示,以便他们可以键入一个注释,他们改变了什么。formview与ajax模式弹出扩展器

这里是我的代码

<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; 
    } 

从我已阅读,应该工作。我试图通过JavaScript在clientclick上显示它。我试图通过在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; 

    } 

} 

所以我才意识到,如果我想让人们不断张贴我需要编辑我原来的职位,而不只是添加注释,所以希望这有助于。无论如何,我仍然无法得到这个工作,我不知道是什么导致我的弹出窗口不被触发?

回答

0

好吧,我终于找到了为什么这不起作用。它归结于虚拟按钮。我设置可见为false来隐藏按钮,并出于某种原因不起作用。一旦我将其更改为style = display:none;它开了罚款。奇怪的是,没有错误抛出它只是从来没有弹出。

+0

样式与asp控件属性不一样。 style =“display:none”与visible =“false”不一样。呈现时请查看HTML代码。 – Fandango68

0

如果您想在用户进行编辑后弹出模式,我不会使用ItemCommand事件。

我还没有使用FormViews,主要是GridViews。但我认为这些原则大体上是相同的。

您是否尝试过在ItemUpdated事件中显示模态?

http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.formview.itemupdated(v=vs.110).aspx

我还没有尝试过,但我想,认为这样的事情可能工作:

试错的许多天之后
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(); 
} 
+0

我也试过。它执行该代码,但仍然只是返回到更新的formview而不显示弹出窗口。出于某种原因,无论我做什么,我都无法看到弹出窗口。 – user1740003

+0

你正在做什么在Page_Load将重写模式? – CodeCanuck

+0

我发布了我的页面加载,但我不认为这会对此产生任何影响。对不起,我没有更早发布我整个周末都感冒了。 – user1740003