I have tried this several ways and none of them seem to work for me. I have a formview and when the user goes into the edit mode and then clicks update I want a modal popup to show so they can type a note as to what they changed.

Here is my code

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

From what I have read that should work. I have tried showing it through javascript on clientclick. I have tried displaying it by calling modal.show() in the itemcommand but none of them are displaying it. Does it matter if the panel or popup are inside or outside the 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;

    }

}

So I just realized if I want people to keep posting I need to edit my original post and not just add a note, so hopefully this helps. Anyway, I still can't get this to work and I don't know what is causing my popup not to fire?

有帮助吗?

解决方案 2

Well after many days of trail and error I finally found out why this wasn't working. It came down to the dummy button. I was setting visible to false to hide the button and for some reason that doesn't work. Once I changed it to style= display:none; it fired fine. Weird that there was no error thrown it was just never popping up.

其他提示

If you want to pop up the modal after the user makes their edits, I wouldn't use the ItemCommand event.

I haven't used FormViews much, mostly GridViews. But I'm assuming that the principles are mostly the same.

Have you tried showing the modal in the ItemUpdated event?

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

I haven't tried this before, but I'd like to think that something like this may work:

 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();
 }
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top