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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Web Development
  3. ASP.NET
  4. How to show a confirmation message box inside a event??

How to show a confirmation message box inside a event??

Scheduled Pinned Locked Moved ASP.NET
tutorialquestion
8 Posts 6 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.
  • S Offline
    S Offline
    Sri_3464
    wrote on last edited by
    #1

    I need to show an confirmation message inside a button click event but only for a particular condition. Not always it should show when the button is clicked. Inside the click event handler i will call a method and depending upon the return value of that method i need to show a confirmation message. How should i do it??? Kindly provide me an idea???

    Thanks, Srikanth

    S I 2 Replies Last reply
    0
    • S Sri_3464

      I need to show an confirmation message inside a button click event but only for a particular condition. Not always it should show when the button is clicked. Inside the click event handler i will call a method and depending upon the return value of that method i need to show a confirmation message. How should i do it??? Kindly provide me an idea???

      Thanks, Srikanth

      S Offline
      S Offline
      srajasekhar
      wrote on last edited by
      #2

      Use this function and call the string required....... public void MsgBox(String str) { System.Text.StringBuilder sb = new System.Text.StringBuilder(); sb.Append(""); sb.Append(@"alert( """ + str + @""" );"); sb.Append(@""); HttpContext.Current.Response.Write(sb.ToString()); } R A J A S E K H A R

      1 Reply Last reply
      0
      • S Sri_3464

        I need to show an confirmation message inside a button click event but only for a particular condition. Not always it should show when the button is clicked. Inside the click event handler i will call a method and depending upon the return value of that method i need to show a confirmation message. How should i do it??? Kindly provide me an idea???

        Thanks, Srikanth

        I Offline
        I Offline
        Imran Khan Pathan
        wrote on last edited by
        #3

        if(condition==true)
        {
        this.Page.ClientScript.RegisterClientScriptBlock(GetType(), "key", "alert('Condition is true')", true);
        }

        bEst rEgard pAthan

        please don't forget to vote on the post that helped you.

        S 1 Reply Last reply
        0
        • I Imran Khan Pathan

          if(condition==true)
          {
          this.Page.ClientScript.RegisterClientScriptBlock(GetType(), "key", "alert('Condition is true')", true);
          }

          bEst rEgard pAthan

          please don't forget to vote on the post that helped you.

          S Offline
          S Offline
          Sri_3464
          wrote on last edited by
          #4

          i dont want an alert message. If the condition is true,say private void button1_click(object s,EventArgs e) { if(Condition == true) { //show confirmation messagei.e with yes no option; //If user click yes continue // if user clicks no return from the event } }

          Thanks, Srikanth

          N V I G 4 Replies Last reply
          0
          • S Sri_3464

            i dont want an alert message. If the condition is true,say private void button1_click(object s,EventArgs e) { if(Condition == true) { //show confirmation messagei.e with yes no option; //If user click yes continue // if user clicks no return from the event } }

            Thanks, Srikanth

            N Offline
            N Offline
            N a v a n e e t h
            wrote on last edited by
            #5

            Sri_3464 wrote:

            //If user click yes continue // if user clicks no return from the event

            I think this might not be possible. When user clicks ok button, page will be posted again AFAIK. Have you tried this ? Replace the alert with confirm

            All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia My Website | Ask smart questions

            1 Reply Last reply
            0
            • S Sri_3464

              i dont want an alert message. If the condition is true,say private void button1_click(object s,EventArgs e) { if(Condition == true) { //show confirmation messagei.e with yes no option; //If user click yes continue // if user clicks no return from the event } }

              Thanks, Srikanth

              V Offline
              V Offline
              varshavmane
              wrote on last edited by
              #6

              Try this: public void MsgBox(String str) { System.Text.StringBuilder sb = new System.Text.StringBuilder(); sb.Append(""); sb.Append(@"if(confirm('Are you sure you want to delete your selection(s)?'){ return true; } else{ return false; })"); sb.Append(@""); HttpContext.Current.Response.Write(sb.ToString()); }

              1 Reply Last reply
              0
              • S Sri_3464

                i dont want an alert message. If the condition is true,say private void button1_click(object s,EventArgs e) { if(Condition == true) { //show confirmation messagei.e with yes no option; //If user click yes continue // if user clicks no return from the event } }

                Thanks, Srikanth

                I Offline
                I Offline
                Imran Khan Pathan
                wrote on last edited by
                #7

                so try this

                if(condition==true)
                {
                this.Page.ClientScript.RegisterClientScriptBlock(GetType(), "key", "return confirm('Condition is true')", true);
                }

                bEst rEgard pAthan

                please don't forget to vote on the post that helped you.

                1 Reply Last reply
                0
                • S Sri_3464

                  i dont want an alert message. If the condition is true,say private void button1_click(object s,EventArgs e) { if(Condition == true) { //show confirmation messagei.e with yes no option; //If user click yes continue // if user clicks no return from the event } }

                  Thanks, Srikanth

                  G Offline
                  G Offline
                  Guffa
                  wrote on last edited by
                  #8

                  That is not possible. The server code is executed on the server to create the response, then the response is sent to the browser. The server code in the page is executed completely, then the response is sent to the browser. If you put code in the resposne that shows a confirmation message, that will not be shown until after the code in the page has been run to completion on the server.

                  Experience is the sum of all the mistakes you have done.

                  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