Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Confirmation Message Box in Code Behind Asp.Net [modified]

Confirmation Message Box in Code Behind Asp.Net [modified]

Scheduled Pinned Locked Moved ASP.NET
csharpasp-nethelp
7 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    priyagee
    wrote on last edited by
    #1

    Hai all, I want to display confirmation message box in Asp.net code behind (C#). When I save the record i am doing some validations , in the validation function i need to display confirmation message with "yes" or "no" , if "yes" the save process should be done and if "no" save process should not be proceed . I have used Page.ClientScript.RegisterStartupScript() ,but it is not working. I have also tried btnSave.Attributes.Add("onclick", "return confirm()"); but the confirmation message is opened before save . I need only at the time of validation . Please Help me. Thank u

    modified on Friday, December 17, 2010 12:42 AM

    H 1 Reply Last reply
    0
    • P priyagee

      Hai all, I want to display confirmation message box in Asp.net code behind (C#). When I save the record i am doing some validations , in the validation function i need to display confirmation message with "yes" or "no" , if "yes" the save process should be done and if "no" save process should not be proceed . I have used Page.ClientScript.RegisterStartupScript() ,but it is not working. I have also tried btnSave.Attributes.Add("onclick", "return confirm()"); but the confirmation message is opened before save . I need only at the time of validation . Please Help me. Thank u

      modified on Friday, December 17, 2010 12:42 AM

      H Offline
      H Offline
      Hiren solanki
      wrote on last edited by
      #2

      <asp:Button ID="btnSave" runat="server" Text="Save" OnClick="btnSave_Click" OnClientClick="return confirm('Do you really want to save?');" />

      Just use this in your button and I am sure it will work definitely.

      Regards, Hiren.

      My Recent Article: - Way to know which control have raised PostBack
      My Recent Tip/Trick: - Remove HTML Tag, get plain Text

      P 1 Reply Last reply
      0
      • H Hiren solanki

        <asp:Button ID="btnSave" runat="server" Text="Save" OnClick="btnSave_Click" OnClientClick="return confirm('Do you really want to save?');" />

        Just use this in your button and I am sure it will work definitely.

        Regards, Hiren.

        My Recent Article: - Way to know which control have raised PostBack
        My Recent Tip/Trick: - Remove HTML Tag, get plain Text

        P Offline
        P Offline
        priyagee
        wrote on last edited by
        #3

        Thanks for the reply I no need to call the function in onClientClick() , that will work fine . I need to call the script function only at the server side validation because the confirmation message should work based on the server side validation. Thank you

        H 1 Reply Last reply
        0
        • P priyagee

          Thanks for the reply I no need to call the function in onClientClick() , that will work fine . I need to call the script function only at the server side validation because the confirmation message should work based on the server side validation. Thank you

          H Offline
          H Offline
          Hiren solanki
          wrote on last edited by
          #4

          Can you please show us Page.ClientScript.RegisterStartupScript(), what you've written inside ?

          Regards, Hiren.

          My Recent Article: - Way to know which control have raised PostBack
          My Recent Tip/Trick: - Remove HTML Tag, get plain Text

          P 1 Reply Last reply
          0
          • H Hiren solanki

            Can you please show us Page.ClientScript.RegisterStartupScript(), what you've written inside ?

            Regards, Hiren.

            My Recent Article: - Way to know which control have raised PostBack
            My Recent Tip/Trick: - Remove HTML Tag, get plain Text

            P Offline
            P Offline
            priyagee
            wrote on last edited by
            #5

            This is my coding protected void btnSave_Click(object sender, Infragistics.WebUI.WebDataInput.ButtonEventArgs e) { try { if (!fnValidate()) return; else { save(); } } catch (Exception ex) { throw(ex); } } bool fnValidate() { Page.ClientScript.RegisterStartupScript(this.GetType(), "ClientScript", ""); } Client side function function confirmUpdate() { var agree = vbConfirm(Are you sure do you want to continue ?'); if (agree == true) { return true; } else { return false; } }</x-turndown>

            H P 2 Replies Last reply
            0
            • P priyagee

              This is my coding protected void btnSave_Click(object sender, Infragistics.WebUI.WebDataInput.ButtonEventArgs e) { try { if (!fnValidate()) return; else { save(); } } catch (Exception ex) { throw(ex); } } bool fnValidate() { Page.ClientScript.RegisterStartupScript(this.GetType(), "ClientScript", ""); } Client side function function confirmUpdate() { var agree = vbConfirm(Are you sure do you want to continue ?'); if (agree == true) { return true; } else { return false; } }</x-turndown>

              H Offline
              H Offline
              Hiren solanki
              wrote on last edited by
              #6

              priyagee wrote:

              Page.ClientScript.RegisterStartupScript(this.GetType(), "ClientScript", "confirmUpdate();</b></blockquote> See that, you haven't closed with <code></script></code>. <div class="signature">Regards, Hiren. <div class="callout align-center" style="margin:1px"><b><font color="red">My Recent Article:</font></b> - <a href="http://www.codeproject.com/KB/aspnet/Postback\_raising\_control.aspx">Way to know which control have raised PostBack</a><br /><b><font color="red">My Recent Tip/Trick:</font></b> - <a href="http://www.codeproject.com/Tips/136704/Remove-all-the-HTML-tags-and-display-a-plain-text-.aspx">Remove HTML Tag, get plain Text</a></div></div></x-turndown>

              1 Reply Last reply
              0
              • P priyagee

                This is my coding protected void btnSave_Click(object sender, Infragistics.WebUI.WebDataInput.ButtonEventArgs e) { try { if (!fnValidate()) return; else { save(); } } catch (Exception ex) { throw(ex); } } bool fnValidate() { Page.ClientScript.RegisterStartupScript(this.GetType(), "ClientScript", ""); } Client side function function confirmUpdate() { var agree = vbConfirm(Are you sure do you want to continue ?'); if (agree == true) { return true; } else { return false; } }</x-turndown>

                P Offline
                P Offline
                PunkIsNotDead
                wrote on last edited by
                #7

                Ajax Modal Pop Up extender has a ".Show" property... here[^] got some help! It's in your imagination the way you need to use the modal! ;)

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups