Community discussion forum

Confirm (MessageBox) in c#, asp.net

  • 8 months ago

    How can I do the confirm in c# and asp.net? The process is,  I have to confirm whether the user is sure that he/she wants to continue. The process of 'continue' is a block of codes (function). If it is yes, it should call the function btnOK_Click. (Is my explanation clear?)

    Please help.. If you need clarifications, please tell me...

     Thanks in advance.. ü

  • Advertisement

    Simply the fastest line-level profiler for .NET ever

    “The low overhead means it has minimal impact on the execution of my program”
    Mark Everest, Development Team Leader, Renault F1 Team Ltd.

    Try out the new ANTS Profiler 4 for yourself. Download your 14-day trial now

  • 8 months ago

     Hi,

     To include a confirmation on your button, you have to include the following script in the HTML code (or add it through your C# code).

    <input type="submit" name="btnSubmit" id="btnSubmit"
         onclick="return confirm('Are you sure you want to Submit?');" />

    With the above code, the button only gets executed (from the browser) if the user presses ok.

    It also depends whether you are using a normal button or a link button.

    try goggling the following: http://www.google.com/search?hl=en&q=asp.net+alert+box&btnG=Search 

    Regards, 

  • 8 months ago

    Hmm, what will I add for if the user clicks on OK, I have to execute a function in the code behind?

    Thanks in advance... ü

  • 8 months ago

    <asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="return confirm('Are you sure?')" onclick="btnOK_Click" />

  • 8 months ago

    That is what I call answer! Many thanks! Yes

  • 8 months ago

    You are welcome Big Smile and thanks you for the thank you.

Post a reply

Enter your message below

Sign in or Join us (it's free).