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. confirmSave alert box,cancel button functionality not working

confirmSave alert box,cancel button functionality not working

Scheduled Pinned Locked Moved ASP.NET
javascriptdatabasesysadminhelpquestion
3 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.
  • U Offline
    U Offline
    User 4467008
    wrote on last edited by
    #1

    Hi, I have written the following code in javascript and when cancel button is clicked in alert box, the record is getting saved and when again second time when cancel button is clicked the functionality of the cancel button in the alertbox is working fine.My issue is at the first time my cancel button is not working and my record is getting saved.can anybody let me know the solution of this issue. function confirmsave() { if(confirm("Are u sure u want to Save Record?")) { return true; } else { document.getElementById('<%=Label22.ClientID %>').innerHTML = "Cancel"; return false; } } <asputton ID="btnsave" runat="server" Style="z-index: 101; left: 420px; position: absolute; top: 37px" Text="Save" Width="64px" OnClientClick="javascript:return confirmsave();" OnClick="btnsave_Click" /> protected void btnsave_Click(object sender, EventArgs e) { if (Page.IsValid == true) { Label22.Visible = true; Label22.Text = " Record Saved "; } } Thanks Ramesh

    B A 2 Replies Last reply
    0
    • U User 4467008

      Hi, I have written the following code in javascript and when cancel button is clicked in alert box, the record is getting saved and when again second time when cancel button is clicked the functionality of the cancel button in the alertbox is working fine.My issue is at the first time my cancel button is not working and my record is getting saved.can anybody let me know the solution of this issue. function confirmsave() { if(confirm("Are u sure u want to Save Record?")) { return true; } else { document.getElementById('<%=Label22.ClientID %>').innerHTML = "Cancel"; return false; } } <asputton ID="btnsave" runat="server" Style="z-index: 101; left: 420px; position: absolute; top: 37px" Text="Save" Width="64px" OnClientClick="javascript:return confirmsave();" OnClick="btnsave_Click" /> protected void btnsave_Click(object sender, EventArgs e) { if (Page.IsValid == true) { Label22.Visible = true; Label22.Text = " Record Saved "; } } Thanks Ramesh

      B Offline
      B Offline
      banker_kiran
      wrote on last edited by
      #2

      Try above code

      Kiran Banker

      1 Reply Last reply
      0
      • U User 4467008

        Hi, I have written the following code in javascript and when cancel button is clicked in alert box, the record is getting saved and when again second time when cancel button is clicked the functionality of the cancel button in the alertbox is working fine.My issue is at the first time my cancel button is not working and my record is getting saved.can anybody let me know the solution of this issue. function confirmsave() { if(confirm("Are u sure u want to Save Record?")) { return true; } else { document.getElementById('<%=Label22.ClientID %>').innerHTML = "Cancel"; return false; } } <asputton ID="btnsave" runat="server" Style="z-index: 101; left: 420px; position: absolute; top: 37px" Text="Save" Width="64px" OnClientClick="javascript:return confirmsave();" OnClick="btnsave_Click" /> protected void btnsave_Click(object sender, EventArgs e) { if (Page.IsValid == true) { Label22.Visible = true; Label22.Text = " Record Saved "; } } Thanks Ramesh

        A Offline
        A Offline
        Arindam Tewary
        wrote on last edited by
        #3

        The code block written looks good and I used the same code block and found that clicking "cancel" working as expected. In your situation if it is not working then try following (1) I suspect that following line might be creating problem and as a result you are not getting correct result. document.getElementById('<%=Label22.ClientID %>').innerHTML = "Cancel"; Change the line to check whether it can find that object as follows, ( I suspect that following line could give 'null' in your actual code block,

        alert(document.getElementById('<%=Label22.ClientID %>'));

        Let me know if it helps,

        Thanks, Arindam D Tewary

        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