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. window.confirm

window.confirm

Scheduled Pinned Locked Moved ASP.NET
helpquestion
4 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.
  • I Offline
    I Offline
    Imran Khan Pathan
    wrote on last edited by
    #1

    hi friends i have one gridview in which i have one delete button .i write code for confirmation to delete on row_deleting events of datagrids. But i am facing from one problem. When first time i click on button then its doesnt give any confirm message after that when i click again then it gives message. Plz help me out my code is protected void GV_userlist_RowDeleting(object sender, GridViewDeleteEventArgs e) { LinkButton bt = (LinkButton)GV_userlist.Rows[e.RowIndex].FindControl("BT_delete"); bt.Attributes.Add("OnClick", "return window.confirm('Are you sure want to remove this user?');"); } thanks

    GOD HELP THOSE WHO HELP THEMSELVES

    A B 2 Replies Last reply
    0
    • I Imran Khan Pathan

      hi friends i have one gridview in which i have one delete button .i write code for confirmation to delete on row_deleting events of datagrids. But i am facing from one problem. When first time i click on button then its doesnt give any confirm message after that when i click again then it gives message. Plz help me out my code is protected void GV_userlist_RowDeleting(object sender, GridViewDeleteEventArgs e) { LinkButton bt = (LinkButton)GV_userlist.Rows[e.RowIndex].FindControl("BT_delete"); bt.Attributes.Add("OnClick", "return window.confirm('Are you sure want to remove this user?');"); } thanks

      GOD HELP THOSE WHO HELP THEMSELVES

      A Offline
      A Offline
      Arun Immanuel
      wrote on last edited by
      #2

      Hi, When the page is first rendered, the link button will not have the onclick attribute. U R adding the confirmation property after the page has been posted back. The newly rendered page will have the link button with onclick attribute set. That is why, the confirmation messaged is displayed for the second time alone. U will have to add the onclick attribute before the page is loaded for the first time. Try this: GV_userlist.Databind(); for(int i=0;i<GV_userlist.Rows.Count;i++) { LinkButton bt = (LinkButton)GV_userlist.Rows[i].FindControl("BT_delete"); bt.Attributes.Add("OnClick", "return window.confirm('Are you sure want to remove this user?');"); }

      Regards, Arun Kumar.A

      S 1 Reply Last reply
      0
      • I Imran Khan Pathan

        hi friends i have one gridview in which i have one delete button .i write code for confirmation to delete on row_deleting events of datagrids. But i am facing from one problem. When first time i click on button then its doesnt give any confirm message after that when i click again then it gives message. Plz help me out my code is protected void GV_userlist_RowDeleting(object sender, GridViewDeleteEventArgs e) { LinkButton bt = (LinkButton)GV_userlist.Rows[e.RowIndex].FindControl("BT_delete"); bt.Attributes.Add("OnClick", "return window.confirm('Are you sure want to remove this user?');"); } thanks

        GOD HELP THOSE WHO HELP THEMSELVES

        B Offline
        B Offline
        badgrs
        wrote on last edited by
        #3

        Why not just add it to the tag in the aspx page? <asp:LinkButton OnClientClick="return window.confirm('Are you sure want to remove this user?');">

        1 Reply Last reply
        0
        • A Arun Immanuel

          Hi, When the page is first rendered, the link button will not have the onclick attribute. U R adding the confirmation property after the page has been posted back. The newly rendered page will have the link button with onclick attribute set. That is why, the confirmation messaged is displayed for the second time alone. U will have to add the onclick attribute before the page is loaded for the first time. Try this: GV_userlist.Databind(); for(int i=0;i<GV_userlist.Rows.Count;i++) { LinkButton bt = (LinkButton)GV_userlist.Rows[i].FindControl("BT_delete"); bt.Attributes.Add("OnClick", "return window.confirm('Are you sure want to remove this user?');"); }

          Regards, Arun Kumar.A

          S Offline
          S Offline
          Sujit Gupta
          wrote on last edited by
          #4

          Call on page load even it will work properly page load() { bt.Attributes.Add("OnClick", "return window.confirm('Are you sure want to remove this user?');"); }

          Sujit

          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