I want to confirm user to proceed the saving .
Let's say I have two processes , Process-One and Process-Two .
After complete Process-One , I want to show confirmation message box to user to proceed saving Process-Two .

  protected void btnSaveProcess_Click(object sender, EventArgs e)
    {
      ..Saving Process-One....
      ..Saving Process-One Complete....
      // here to show "Are you sure you want to Save Process-Two"
      //if user confirm "OK" , save Process-Two 
      //if user "Cancel" , stop and cancel saving Process-Two

    }

Actually , I'm a little weak in Javascript . How can I make this process using Javascript ?
TIA :)

有帮助吗?

解决方案

Since you said you are not great with javascript, you can try this. Break the process into 2 buttons, first part is done in btnSaveProcess_Click, and now make a second button btnSecond. btnSecond will handle the second part, after btnSaveProcess_Click is done have it trigger the click event of the btnSecond button. when you create the btnSecond set it up with an alert like:

<asp:Button id="btnSecond" Text="2nd Button" CssClass="HideMe" runat="server" OnClientClick="javascript:return confirm('Would you like to proceed?');"/>

this way the 1st button completes and calls the 2nd ones click. that will cause the alert to come up, if the user clicks ok it proceeds to the 2nd ones event, if the user hits no it doesn't continue.

其他提示

you could use the ASP.NET AJAX Control Toolkit. it has a ConfirmButtonExtender that will show a confirm dialog before triggering the asp.net postback.

if you want some thing more lightweight you could add the following to a asp.net button onClientClick="return confirm('Are you sure?');"

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top