ModalPopupExtender Buttons Not working

Last post 10-07-2009 12:12 PM by spook_man. 6 replies.

Sort Posts:

  • ModalPopupExtender Buttons Not working

    10-07-2009, 10:01 AM
    • Member
      30 point Member
    • spook_man
    • Member since 08-12-2008, 12:05 PM
    • Posts 118

    Hello..  I have a webpage which when an item is added to a database and there's a duplicate entry in the database, a ModalPopup opens asking the end-user if they want to go ahead and add this duplicate item to the database or don't add the item.  This modal is opened by the code-behind; if there is a duplicate item boolean is set to True and the modal is shown "MPEDuplicateParcel.Show()".

    The modal has two buttons, add or dont add.  But when I click on them, they're not working.  What am I missing?  Thanks.. -Jeff

    Main Page:

        <ajaxToolkit:ModalPopupExtender ID="MPEDuplicateParcel" runat="server"
            BackgroundCssClass="modalBackground"
            Dropshadow="true"
            OkControlId="btnModalAdd"
            CancelControlId="btnModalDontAdd"
            PopupControlID="pnlModalPopup"
            TargetControlID="pnlModalPopup">
        </ajaxToolkit:ModalPopupExtender>
        
        <asp:Panel ID="pnlModalPopup" runat="server" CssClass="modalPopup" style="display:none;"> 
            <asp:Label ID="lbl_ModalPopup" runat="server"></asp:Label>
            <br /><br /> 
            <asp:Button ID="btnModalAdd" runat="server" Text="Please Add" /> 
            <asp:Button ID="btnModalDontAdd" runat="server" Text="Don't Add" /> 
        </asp:Panel>

    Code-Behind:

    ElseIf DuplicateParcel = True Then
        MPEDuplicateParcel.Show()
    End If

    Button Events:

    Protected Sub btnModalAdd_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnModalAdd.Click
        UpdateMemberDuplicateParcel()
    End Sub
    
    Protected Sub btnModalDontAdd_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnModalDontAdd.Click
        DontUpdateMemberDuplicateParcel()
    End Sub


     

     

     

     

  • Re: ModalPopupExtender Buttons Not working

    10-07-2009, 10:25 AM
    • Contributor
      5,011 point Contributor
    • karthicks
    • Member since 01-09-2009, 12:43 PM
    • Chennai
    • Posts 862

    hi,

    check any validation controls are firing while clicking the modal pop buttons and also ensure events are properly registered 

    If this post is useful,
    Please,Dont Forget to click Mark As Answer and Earn Your Point

    Thanks,
    Karthick S
    Celebrate Programming
  • Re: ModalPopupExtender Buttons Not working

    10-07-2009, 10:36 AM
    Answer

    <asp:Button  Style="Display:none" ID="BtnTemp" runat="server" UseSubmitBehavior="False" Text="Please Add" />   

    Add a button in your web page and set OkControlId="BtnTemp" and CancelControlId="BtnTemp"and show and hide your Modalpopup on click event of OK/Cancel button (or you can use javascript function).

    If you want to avoid postback then put your panel inside the update panel.



    --------------------
    S.K.Gautam
    New Delhi(INDIA)
    -------------------
    Please mark the answer if it helped you


  • Re: ModalPopupExtender Buttons Not working

    10-07-2009, 10:42 AM
    • Member
      30 point Member
    • spook_man
    • Member since 08-12-2008, 12:05 PM
    • Posts 118

    gautam2u@gmail.com:

    <asp:Button  Style="Display:none" ID="BtnTemp" runat="server" Text="Please Add" />   

    Add a button in your web page and set OkControlId="BtnTemp" and CancelControlId="BtnTemp"and show and hide our Modalpopup on click event of OK/Cancel button (or you can use javascript function).

    If you want to avoid postback then put your panel inside the update panel.
     

    Hello, thank you for your reply.  This won't work because I want the modal pop-up to open whether certain criteria is met, not due to a button click.  It's the buttons within the modal which aren't working.  And I can't figure out why.  Thanks..

  • Re: ModalPopupExtender Buttons Not working

    10-07-2009, 10:48 AM
    • Member
      30 point Member
    • spook_man
    • Member since 08-12-2008, 12:05 PM
    • Posts 118

    karthicks:

    hi,

    check any validation controls are firing while clicking the modal pop buttons and also ensure events are properly registered 

     

    Hello.. Thank you for the reply..  I tried setting the CausesValidation of the buttons to true and false, but neither worked.  I'm debugging in VS2008 and added a break at the  Protected Sub btnModalAdd_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnModalAdd.Click event in the behind the code, but it doesn't stop there.

    Maybe, I didn't explain what is happening correctly.  There isn't any kind of even firing for the buttons.  If I click on either button, it just sits there.  I can click all I want and until my finger gets tired, but nothing happens.  Not sure what is going on and why these events are firing.

    Thanks.. -Jeff

  • Re: ModalPopupExtender Buttons Not working

    10-07-2009, 11:49 AM
    • Member
      30 point Member
    • spook_man
    • Member since 08-12-2008, 12:05 PM
    • Posts 118

    I even tried adding OnClick="btnModalAdd_Click" to the buttons, but no event is being fired when I click on the button.  It's almost like the Javascript isn't running properly.

    No errors are occurring when I debug the code.  I don't know anymore.  UGH.

  • Re: ModalPopupExtender Buttons Not working

    10-07-2009, 12:12 PM
    • Member
      30 point Member
    • spook_man
    • Member since 08-12-2008, 12:05 PM
    • Posts 118

    gautam2u@gmail.com:

    <asp:Button  Style="Display:none" ID="BtnTemp" runat="server" UseSubmitBehavior="False" Text="Please Add" />   

    Add a button in your web page and set OkControlId="BtnTemp" and CancelControlId="BtnTemp"and show and hide your Modalpopup on click event of OK/Cancel button (or you can use javascript function).

    If you want to avoid postback then put your panel inside the update panel.
     

    Oh man, I feel bad.  I was able to get it working by adding the UseSubmitBehavior="False" in the button code.  Upon doing this, the event was firing correctly.  Thank you for the suggestion.  Marked as answer.  -Jeff

Page 1 of 1 (7 items)