server click event firing before javascript confirmation RRS feed

  • Question

  • User-153404742 posted

    I have a linkButton where I've defined server side click event and client side click event as follows;

    <asp:LinkButton ID="lbRename" runat="server" OnClick="lbRename_Click" OnClientClick="externalAction('rename')"/>

    the rename function on client side is a bootbox prompt, which handles delete only if the user selects OK.  inside the handleRename function, I'm just setting the id and the name from the prompt into a hiddenField variable value.  Problem is, the "lbRename_Click" event fires before user clicks ok or cancel on the bootbox prompt window...How do I ensure that this event completes firing and the user has made a selection and the bootbox is closed before firing the OnClick event on the server side?  If I use the regular return confirm("....") for the OnClientClick, it works fine....

                                    title: "Rename " + name,
                                    value: name,
                                    centerVertical: true,
                                    callback: function (result) {
                                        if (result) {
                                            handleRename(data.id, result);

    Tuesday, October 6, 2020 9:28 PM

All replies

  • User475983607 posted

    Use a link to open the prompt not a linkbutton.  Read the bootstrap docs to understand how to open the prompt.  In the bootstrap prompt use  the linkbutton for the OK or a standard button. 

    The problem is the link button causes a postback and you do not want a postback.  You want to open the prompt first.  Then you want to execute a post back if the user clicks the OK button.

    Tuesday, October 6, 2020 10:10 PM
  • User-153404742 posted

    I have UI already designed that I'm using, which has regular html <button> which is not runat=server control...however, I need to call a function in the code behind to process the handling...how would I call a function in the code behind from javascript without actually making the onClick event for an <asp:button runat="server"....> control? and possibly not using the asp server button control?

    Wednesday, October 7, 2020 5:59 PM
  • User-1330468790 posted

    Hi inkaln,


    Could you please confirm that how you want to handle the rename? 

    If it is not related to controls in currently page, you could use an ajax call to call the code behind function which should be prefixed with [WebMethod] attribute.

     Related links:




    Hope helps.

    Best regards,


    Monday, October 12, 2020 9:44 AM
  • User-474980206 posted

    Your issue is that unlike confirm, boot box is async. The client click should cancel the post back event. The confirm callback of the boot box should do the post back.

    Thursday, October 15, 2020 2:37 PM