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. How to perform this requirement

How to perform this requirement

Scheduled Pinned Locked Moved ASP.NET
javascripttoolshelptutorialquestion
10 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.
  • N Offline
    N Offline
    Nath
    wrote on last edited by
    #1

    I am using this: btnDelete.Attributes.Add("onclick", "if(confirm('Are you sure you want to delete?')) Test1();else return false;") my requirement is to be excute the function test1() but nothing happend and iam also trying in this manner could anyone help me Page.RegisterStartupScript("Confirm", "<script language=JavaScript>Confirm();</script>"); and in the aspx file (desiner) you need to write the following code <script language="javascript" type="text/javascript"> Function Confirm() //Sample Function { var blnConfirm = confirm("sample function to test confirm function"); if(blnConfirm == true) { alert("you have clicked yes"); return false; } else { alert("you have clicked No"); } } </script>

    T N 2 Replies Last reply
    0
    • N Nath

      I am using this: btnDelete.Attributes.Add("onclick", "if(confirm('Are you sure you want to delete?')) Test1();else return false;") my requirement is to be excute the function test1() but nothing happend and iam also trying in this manner could anyone help me Page.RegisterStartupScript("Confirm", "<script language=JavaScript>Confirm();</script>"); and in the aspx file (desiner) you need to write the following code <script language="javascript" type="text/javascript"> Function Confirm() //Sample Function { var blnConfirm = confirm("sample function to test confirm function"); if(blnConfirm == true) { alert("you have clicked yes"); return false; } else { alert("you have clicked No"); } } </script>

      T Offline
      T Offline
      thatraja
      wrote on last edited by
      #2

      use this code

      Custom ConFirm, Alert and Prompt
      function FnConfirm()
      {
      var ans=confirm("Choose a button")
      if (ans==true)
      {
      alert("You pressed OK");
      FngoOK();
      }
      else
      {
      alert("You pressed Cancel");
      FngoCancel();
      }
      }
      function FngoOK()
      {
      window.location = "OK.htm";
      }
      function FngoCancel()
      {
      window.location = "Cancel.htm";
      }

      i tried this & working. For server side you can do like this

      btnDelete.Attributes.Add("onclick", "FnConfirm()")

      N N 2 Replies Last reply
      0
      • N Nath

        I am using this: btnDelete.Attributes.Add("onclick", "if(confirm('Are you sure you want to delete?')) Test1();else return false;") my requirement is to be excute the function test1() but nothing happend and iam also trying in this manner could anyone help me Page.RegisterStartupScript("Confirm", "<script language=JavaScript>Confirm();</script>"); and in the aspx file (desiner) you need to write the following code <script language="javascript" type="text/javascript"> Function Confirm() //Sample Function { var blnConfirm = confirm("sample function to test confirm function"); if(blnConfirm == true) { alert("you have clicked yes"); return false; } else { alert("you have clicked No"); } } </script>

        N Offline
        N Offline
        Not Active
        wrote on last edited by
        #3

        Nath wrote:

        Page.RegisterStartupScript("Confirm", "Confirm();");

        It is unnecessary to register the confirm script since you have already included it in the page.

        function Confirm()
        {
            if (confirm("Are you sure you want to delete?"))
                alert("Yes");
            else
                alert("No");
        }
        

        I know the language. I've read a book. - _Madmatt

        1 Reply Last reply
        0
        • T thatraja

          use this code

          Custom ConFirm, Alert and Prompt
          function FnConfirm()
          {
          var ans=confirm("Choose a button")
          if (ans==true)
          {
          alert("You pressed OK");
          FngoOK();
          }
          else
          {
          alert("You pressed Cancel");
          FngoCancel();
          }
          }
          function FngoOK()
          {
          window.location = "OK.htm";
          }
          function FngoCancel()
          {
          window.location = "Cancel.htm";
          }

          i tried this & working. For server side you can do like this

          btnDelete.Attributes.Add("onclick", "FnConfirm()")

          N Offline
          N Offline
          Not Active
          wrote on last edited by
          #4

          thatraja wrote:

          btnDelete.Attributes.Add("onclick", "FnConfirm()")

          Won't work without runat=Server on the input element. Where did the OP ask about redirecting pages? and you are using far too much code to accomplish the very simple task

          thatraja wrote:

          var ans=confirm("Choose a button")

          You are uselessly creating another variable when this is enough if( confirm("Choose a button") ) ... else ...


          I know the language. I've read a book. - _Madmatt

          T 1 Reply Last reply
          0
          • N Not Active

            thatraja wrote:

            btnDelete.Attributes.Add("onclick", "FnConfirm()")

            Won't work without runat=Server on the input element. Where did the OP ask about redirecting pages? and you are using far too much code to accomplish the very simple task

            thatraja wrote:

            var ans=confirm("Choose a button")

            You are uselessly creating another variable when this is enough if( confirm("Choose a button") ) ... else ...


            I know the language. I've read a book. - _Madmatt

            T Offline
            T Offline
            thatraja
            wrote on last edited by
            #5

            |Mark Nischalke wrote 1.Won't work without runat=Server on the input element. 2.Where did the OP ask about redirecting pages? and you are using far too much code to accomplish the very simple task 3.You are uselessly creating another variable when this is enough =>1. I gave him a full HTML code and I was mentioned server side code will be like

            btnDelete.Attributes.Add("onclick", "FnConfirm()")

            instead of

            btnDelete.Attributes.Add("onclick", "if(confirm('Are you sure you want to delete?')) Test1();else return false;")

            also it wasn't mentioned as a client control by neither me or him. =>2.Actually he called a function Test1() in his code so that i was created a 2 dummy functions for redirects based on the response for easy understand to him. =>3.Here i copied his code & made some changes & posted here so i didn't created any new variable. Happy coding :) Thanks Regards, thatraja

            N 1 Reply Last reply
            0
            • T thatraja

              |Mark Nischalke wrote 1.Won't work without runat=Server on the input element. 2.Where did the OP ask about redirecting pages? and you are using far too much code to accomplish the very simple task 3.You are uselessly creating another variable when this is enough =>1. I gave him a full HTML code and I was mentioned server side code will be like

              btnDelete.Attributes.Add("onclick", "FnConfirm()")

              instead of

              btnDelete.Attributes.Add("onclick", "if(confirm('Are you sure you want to delete?')) Test1();else return false;")

              also it wasn't mentioned as a client control by neither me or him. =>2.Actually he called a function Test1() in his code so that i was created a 2 dummy functions for redirects based on the response for easy understand to him. =>3.Here i copied his code & made some changes & posted here so i didn't created any new variable. Happy coding :) Thanks Regards, thatraja

              N Offline
              N Offline
              Not Active
              wrote on last edited by
              #6

              From your profile we can see you are not very proficient in these technologies. Perhaps do more studying before responding and answering.

              thatraja wrote:

              btnDelete.Attributes.Add("onclick", "FnConfirm()")

              This server side code can not be be called unless the client side element has the runat=Server attribute.

              thatraja wrote:

              =>2.Actually he called a function Test1() in his code so that i was created a 2 dummy functions for redirects based on the response for easy understand to him.

              Again, where is it stated by the OP that a redirected was needed? By added unnecessary features you may have done more to confuse than to help.

              thatraja wrote:

              =>3.Here i copied his code & made some changes & posted here so i didn't created any new variable.

              From this we can tell you are probably very profeccient at copy and paste coding and don't fully understand what you are doing. If you knew what you where doing you should have corrected the OPs code and explained why.


              I know the language. I've read a book. - _Madmatt

              T 1 Reply Last reply
              0
              • N Not Active

                From your profile we can see you are not very proficient in these technologies. Perhaps do more studying before responding and answering.

                thatraja wrote:

                btnDelete.Attributes.Add("onclick", "FnConfirm()")

                This server side code can not be be called unless the client side element has the runat=Server attribute.

                thatraja wrote:

                =>2.Actually he called a function Test1() in his code so that i was created a 2 dummy functions for redirects based on the response for easy understand to him.

                Again, where is it stated by the OP that a redirected was needed? By added unnecessary features you may have done more to confuse than to help.

                thatraja wrote:

                =>3.Here i copied his code & made some changes & posted here so i didn't created any new variable.

                From this we can tell you are probably very profeccient at copy and paste coding and don't fully understand what you are doing. If you knew what you where doing you should have corrected the OPs code and explained why.


                I know the language. I've read a book. - _Madmatt

                T Offline
                T Offline
                thatraja
                wrote on last edited by
                #7

                You are right mate, still didn't completed my Master degree & i hope it will take a year to complete. And now i'm started to studying in latest things in those technologies so that i joined also Codeproject this month which is nice. |Mark Nischalke wrote This server side code can not be be called unless the client side element has the runat=Server attribute. but here the btnDelete is a server side element so that i was added the attribute in runtime. Again, where is it stated by the OP that a redirected was needed? By added unnecessary features you may have done more to confuse than to help. I accept this one my mistake because i didn't thought about his confusion by the redirection code. It would be better if i put those alert messages instead of redirections inside those dummy functions. **From this we can tell you are probably very proficient at copy and paste coding and don't fully understand what you are doing. If you knew what you where doing you should have corrected the OPs code and explained why.**Actually already he was posted some sample code which has some issue. But i thought it would be better to make some changes in that code instead of writing an new one because he may be confuse here too. Also i have waited for his response. That's all. Thanks for your feedback Mate can you help me for my study by preferring things in technologies. Also i have visited your profile page but your blog isn't write mode for me. how to contact you? Please help. Thanks. :)

                N 1 Reply Last reply
                0
                • T thatraja

                  use this code

                  Custom ConFirm, Alert and Prompt
                  function FnConfirm()
                  {
                  var ans=confirm("Choose a button")
                  if (ans==true)
                  {
                  alert("You pressed OK");
                  FngoOK();
                  }
                  else
                  {
                  alert("You pressed Cancel");
                  FngoCancel();
                  }
                  }
                  function FngoOK()
                  {
                  window.location = "OK.htm";
                  }
                  function FngoCancel()
                  {
                  window.location = "Cancel.htm";
                  }

                  i tried this & working. For server side you can do like this

                  btnDelete.Attributes.Add("onclick", "FnConfirm()")

                  N Offline
                  N Offline
                  Nath
                  wrote on last edited by
                  #8

                  Thanks for your help and i was to new to work with javascript and if user clicks on ok then i have to redirect to another page that is happening if on cancel then i have to focus him on a text control. I will try for that. once again very thanks for your help

                  T 1 Reply Last reply
                  0
                  • N Nath

                    Thanks for your help and i was to new to work with javascript and if user clicks on ok then i have to redirect to another page that is happening if on cancel then i have to focus him on a text control. I will try for that. once again very thanks for your help

                    T Offline
                    T Offline
                    thatraja
                    wrote on last edited by
                    #9

                    use the following script

                    function FnConfirm()
                    {
                    if (confirm("Choose a button"))
                    {
                    window.location = "anotherpage.htm";//If OK button pressed
                    }
                    else
                    {
                    document.getElementById('anothertextbox').focus();//If Cancel button pressed
                    }
                    }

                    Here 'anothertextbox' is the name of your another textbox.

                    1 Reply Last reply
                    0
                    • T thatraja

                      You are right mate, still didn't completed my Master degree & i hope it will take a year to complete. And now i'm started to studying in latest things in those technologies so that i joined also Codeproject this month which is nice. |Mark Nischalke wrote This server side code can not be be called unless the client side element has the runat=Server attribute. but here the btnDelete is a server side element so that i was added the attribute in runtime. Again, where is it stated by the OP that a redirected was needed? By added unnecessary features you may have done more to confuse than to help. I accept this one my mistake because i didn't thought about his confusion by the redirection code. It would be better if i put those alert messages instead of redirections inside those dummy functions. **From this we can tell you are probably very proficient at copy and paste coding and don't fully understand what you are doing. If you knew what you where doing you should have corrected the OPs code and explained why.**Actually already he was posted some sample code which has some issue. But i thought it would be better to make some changes in that code instead of writing an new one because he may be confuse here too. Also i have waited for his response. That's all. Thanks for your feedback Mate can you help me for my study by preferring things in technologies. Also i have visited your profile page but your blog isn't write mode for me. how to contact you? Please help. Thanks. :)

                      N Offline
                      N Offline
                      Nath
                      wrote on last edited by
                      #10

                      I cant get you what you have studied if you are going to assist me in learning technology i would be greatful and my mail id is mca.nath@gmail.com you can contact me through this maild Thanks & Regards, K. Amarnath.

                      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