locked
modalpopup extender buttons do nothing RRS feed

  • Question

  • User-962670764 posted

    I have a gridview that users can add items to.  The Add Bike button opens a modal popup that they can enter values in but when you press the add bike button the popup closes and the onclick event for the button never fires. Debugging it, the break on that point is not touched. ASPX:

    <asp:Panel ID="pnlbikelist" runat="server" CssClass="modalPanel" Width="265" style="display:none;">
                <table >
                    <tr>
                        <td>
                            <asp:Label ID="lblyr" runat="server" Text="Year:" Width="100"></asp:Label>
                        </td>
                        <td>
                            <asp:TextBox ID="tbyear" runat="server" Width="125" /></td>
                    </tr>
                    <tr>
                        <td>
                            <asp:Label ID="lblmk" runat="server" Text="Make:" Width="100"></asp:Label>
                        </td>
                        <td> <asp:TextBox ID="tbmake" runat="server" Width="125" /></td>
                    </tr>
                    <tr>
                        <td> <asp:Label ID="lblmdl" runat="server" Text="Model:" Width="100"></asp:Label>
                        </td>
                        <td> <asp:TextBox ID="tbmodel" runat="server" Width="125" /></td>
                     </tr>
                    <tr>
                        <td> <asp:Label ID="lbltgyp" runat="server" Text="Type:" Width="100"></asp:Label>
                        </td>
                        <td> <asp:DropDownList ID="ddltype" runat="server" DataSourceID="dsbiketype" DataTextField="biketype" DataValueField="biketypeid"></asp:DropDownList>
                            <asp:SqlDataSource ID="dsbiketype" runat="server" ConnectionString="<%$ ConnectionStrings:BDUCConnectionString %>" SelectCommand="UM_biketypes" SelectCommandType="StoredProcedure"></asp:SqlDataSource>
                        </td>
                    </tr>
                    <tr>
                        <td ><asp:Label ID="lbcmt" runat="server" Text="Comment:" Width="100"></asp:Label>
                        </td>
                        <td> <asp:TextBox ID="tbdesc" runat="server" Width="125" /></td>
                      </tr>
                    <tr>
                        <td colspan="2" >
                            <asp:Button ID="btnsavebikes" runat="server" Enabled="true" Text="Save" OnClick="btnsavebikes_Click" CommandName="savebike" CommandArgument="Session[RID]" OnCommand="btnsavebikes_Command" Width="42px" />
                            &nbsp;<asp:Button ID="btncan" runat="server" Text="Cancel" OnClick="btncan_Click" />                                                                                                                                                                                                                                                                                                                                                                                                                                                 
                        </td>
                        
                    </tr>
                </table>
    
            </asp:Panel>
    
    
    
            <asp:Button ID="Button2" runat="server" Text="Button" style="display:none;" />
            <ajaxToolkit:ModalPopupExtender ID="pnlbikelist_ModalPopupExtender" runat="server" 
                BehaviorID="pnlbikelist_ModalPopupExtender" TargetControlID="Button2" PopupControlID="pnlbikelist" OkControlID="btnsavebikes" CancelControlID="btncan">
            </ajaxToolkit:ModalPopupExtender>

    C#:

      protected void btnsavebikes_Click(object sender, System.EventArgs e)
        {
            utility ut = new utility();
            ut.addbike(rid, tbyear.Text, tbmake.Text, tbmodel.Text, tbdesc.Text, Convert.ToInt32(ddltype.SelectedValue));
        }

    the ut.addbike method works if run alone, the problem is the popup closes without ever running it.

    Wednesday, January 27, 2016 4:14 AM

Answers

  • User1724605321 posted

    Hi dieseldave,

    Please try to remove OkControlID from your ModalPopupExtender:

    OkControlID="btnsavebikes"

    And then debug your application and check whether the event fires .

    Best Regards,

    Nan Yu

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, January 27, 2016 7:01 AM