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. No PostBack For OnClientClick On GridView Button

No PostBack For OnClientClick On GridView Button

Scheduled Pinned Locked Moved ASP.NET
helpjavascriptdesignquestion
5 Posts 4 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.
  • M Offline
    M Offline
    michaelastewartmas
    wrote on last edited by
    #1

    I have been attempting to add a Confirmation Popup to a Button that comes from a ButtonField in a GridView. I have successfully identified the Button and added the Javascript with the code below. When I press the Button, a Confirmation Popup comes up with the "Ok" or "Cancel" buttons as usual. The problem is that when I press the "Ok" button….no post back is made. I can't figure it out. Is there some kind of special consideration that I missed with adding this kind of confirmation to a Button from a ButtonField? Private Sub gv_MaterialGrpLegacy_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles gv_MaterialGrpLegacy.RowDataBound ... Dim RowButton As Button RowButton = e.Row.Cells(0).Controls(0) RowButton.OnClientClick = String.Format("javascript:return confirm('Are You Sure You Want To Remove This {0}?');", "") Thanks to all that have help me in the past, and those who can help me with this!

    M F M 4 Replies Last reply
    0
    • M michaelastewartmas

      I have been attempting to add a Confirmation Popup to a Button that comes from a ButtonField in a GridView. I have successfully identified the Button and added the Javascript with the code below. When I press the Button, a Confirmation Popup comes up with the "Ok" or "Cancel" buttons as usual. The problem is that when I press the "Ok" button….no post back is made. I can't figure it out. Is there some kind of special consideration that I missed with adding this kind of confirmation to a Button from a ButtonField? Private Sub gv_MaterialGrpLegacy_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles gv_MaterialGrpLegacy.RowDataBound ... Dim RowButton As Button RowButton = e.Row.Cells(0).Controls(0) RowButton.OnClientClick = String.Format("javascript:return confirm('Are You Sure You Want To Remove This {0}?');", "") Thanks to all that have help me in the past, and those who can help me with this!

      M Offline
      M Offline
      Mayank Prajapati
      wrote on last edited by
      #2

      I am using this, and its working fine.

      With Regards, Mayank Prajapati MCP, MCTS Module Leader JCTWeb India www.jctweb.com

      1 Reply Last reply
      0
      • M michaelastewartmas

        I have been attempting to add a Confirmation Popup to a Button that comes from a ButtonField in a GridView. I have successfully identified the Button and added the Javascript with the code below. When I press the Button, a Confirmation Popup comes up with the "Ok" or "Cancel" buttons as usual. The problem is that when I press the "Ok" button….no post back is made. I can't figure it out. Is there some kind of special consideration that I missed with adding this kind of confirmation to a Button from a ButtonField? Private Sub gv_MaterialGrpLegacy_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles gv_MaterialGrpLegacy.RowDataBound ... Dim RowButton As Button RowButton = e.Row.Cells(0).Controls(0) RowButton.OnClientClick = String.Format("javascript:return confirm('Are You Sure You Want To Remove This {0}?');", "") Thanks to all that have help me in the past, and those who can help me with this!

        M Offline
        M Offline
        Mayank Prajapati
        wrote on last edited by
        #3

        i am using this and its working fine With Regards, Mayank Prajapati MCP, MCTS Sr. Software Engineer JCTWeb India www.jctweb.com

        1 Reply Last reply
        0
        • M michaelastewartmas

          I have been attempting to add a Confirmation Popup to a Button that comes from a ButtonField in a GridView. I have successfully identified the Button and added the Javascript with the code below. When I press the Button, a Confirmation Popup comes up with the "Ok" or "Cancel" buttons as usual. The problem is that when I press the "Ok" button….no post back is made. I can't figure it out. Is there some kind of special consideration that I missed with adding this kind of confirmation to a Button from a ButtonField? Private Sub gv_MaterialGrpLegacy_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles gv_MaterialGrpLegacy.RowDataBound ... Dim RowButton As Button RowButton = e.Row.Cells(0).Controls(0) RowButton.OnClientClick = String.Format("javascript:return confirm('Are You Sure You Want To Remove This {0}?');", "") Thanks to all that have help me in the past, and those who can help me with this!

          F Offline
          F Offline
          firozu
          wrote on last edited by
          #4

          michaelastewartmas wrote:

          Dim RowButton As Button RowButton = e.Row.Cells(0).Controls(0) RowButton.OnClientClick = String.Format("javascript:return confirm('Are You Sure You Want To Remove This {0}?');", "")

          Try binding 'Click' or 'Command' event to button which executes on the server when button is clicked. e.g. - RowButton.Click += new EventHandler(this.RowButton_Click);

          1 Reply Last reply
          0
          • M michaelastewartmas

            I have been attempting to add a Confirmation Popup to a Button that comes from a ButtonField in a GridView. I have successfully identified the Button and added the Javascript with the code below. When I press the Button, a Confirmation Popup comes up with the "Ok" or "Cancel" buttons as usual. The problem is that when I press the "Ok" button….no post back is made. I can't figure it out. Is there some kind of special consideration that I missed with adding this kind of confirmation to a Button from a ButtonField? Private Sub gv_MaterialGrpLegacy_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles gv_MaterialGrpLegacy.RowDataBound ... Dim RowButton As Button RowButton = e.Row.Cells(0).Controls(0) RowButton.OnClientClick = String.Format("javascript:return confirm('Are You Sure You Want To Remove This {0}?');", "") Thanks to all that have help me in the past, and those who can help me with this!

            M Offline
            M Offline
            meeram395
            wrote on last edited by
            #5

            Hi, Try to get the return value. If the user clicks OK button, it will be true, otherwise false. Postback only happens if it is true.

            Meeram395

            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