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. Javascript Alert Box does not Display

Javascript Alert Box does not Display

Scheduled Pinned Locked Moved ASP.NET
csharpjavascriptasp-netcom
6 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.
  • V Offline
    V Offline
    Vimalsoft Pty Ltd
    wrote on last edited by
    #1

    Good Evening Guys, Today its my Birthaday. :) I have a If statement that i use to return an integer that will mean Success or Failure , now am testing for that integer in my ASP.NET 2.0 Page lke this

    if (Res == 1)
    {

    Response.Write(@"<script> alert('You have Successfully Registred');</script>");

            Response.Redirect("login.aspx", false);
        }
        else
        {
    

    Response.Write(@"<script> alert('Invalid Data has been Entered');</script>");

    Now if the value is 1, then it should Display the Message and after the Message has been Clicked it should move to the login Page. Now my Problem is that it moves to the Login Page without a Alert Message being Displayed And the send Alert for invalid Entry, will not show anythingm, there is a Warning sign on my Page at the Bootom left of my Page. What is wrong with my Javascript Thanks

    Vuyiswa Maseko, Sorrow is Better than Laughter, it may Sadden your Face, but It sharpens your Understanding VB.NET/SQL7/2000/2005 http://vuyiswamb.007ihost.com http://Ecadre.007ihost.com vuyiswam@tshwane.gov.za

    G N S 3 Replies Last reply
    0
    • V Vimalsoft Pty Ltd

      Good Evening Guys, Today its my Birthaday. :) I have a If statement that i use to return an integer that will mean Success or Failure , now am testing for that integer in my ASP.NET 2.0 Page lke this

      if (Res == 1)
      {

      Response.Write(@"<script> alert('You have Successfully Registred');</script>");

              Response.Redirect("login.aspx", false);
          }
          else
          {
      

      Response.Write(@"<script> alert('Invalid Data has been Entered');</script>");

      Now if the value is 1, then it should Display the Message and after the Message has been Clicked it should move to the login Page. Now my Problem is that it moves to the Login Page without a Alert Message being Displayed And the send Alert for invalid Entry, will not show anythingm, there is a Warning sign on my Page at the Bootom left of my Page. What is wrong with my Javascript Thanks

      Vuyiswa Maseko, Sorrow is Better than Laughter, it may Sadden your Face, but It sharpens your Understanding VB.NET/SQL7/2000/2005 http://vuyiswamb.007ihost.com http://Ecadre.007ihost.com vuyiswam@tshwane.gov.za

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

      You can not send two responses to one request, so you can't both have a page containing the Javascript and a page for the redirect. When you do the redirect the current page (where you added the script) is scrapped, and a redirect page is sent instead. So the reason that the alert doesn't show up is that you removed it. You either have to make the login page show the alert, or do the redirect using Javascript. When you get a warning sign at the bottom of the page, there is an error message. Double click the warning sign to display the error message. It's probably because you put the script in the wrong place in the page. You should not use Response.Write at all, unless you take over the responsability for the page completely and write out the entire page with Response.Write. If you use Response.Write to put the script in the page, you will write it before the actual html document, which will keep it from working properly. Use the ClientScript.RegisterStartupScript method to add scripts to the page.

      Despite everything, the person most likely to be fooling you next is yourself.

      1 Reply Last reply
      0
      • V Vimalsoft Pty Ltd

        Good Evening Guys, Today its my Birthaday. :) I have a If statement that i use to return an integer that will mean Success or Failure , now am testing for that integer in my ASP.NET 2.0 Page lke this

        if (Res == 1)
        {

        Response.Write(@"<script> alert('You have Successfully Registred');</script>");

                Response.Redirect("login.aspx", false);
            }
            else
            {
        

        Response.Write(@"<script> alert('Invalid Data has been Entered');</script>");

        Now if the value is 1, then it should Display the Message and after the Message has been Clicked it should move to the login Page. Now my Problem is that it moves to the Login Page without a Alert Message being Displayed And the send Alert for invalid Entry, will not show anythingm, there is a Warning sign on my Page at the Bootom left of my Page. What is wrong with my Javascript Thanks

        Vuyiswa Maseko, Sorrow is Better than Laughter, it may Sadden your Face, but It sharpens your Understanding VB.NET/SQL7/2000/2005 http://vuyiswamb.007ihost.com http://Ecadre.007ihost.com vuyiswam@tshwane.gov.za

        N Offline
        N Offline
        ncsubbu
        wrote on last edited by
        #3

        Page.RegisterStartupScript("hai", "alert('hai')") the above display alert box

        your's subbu

        V 1 Reply Last reply
        0
        • V Vimalsoft Pty Ltd

          Good Evening Guys, Today its my Birthaday. :) I have a If statement that i use to return an integer that will mean Success or Failure , now am testing for that integer in my ASP.NET 2.0 Page lke this

          if (Res == 1)
          {

          Response.Write(@"<script> alert('You have Successfully Registred');</script>");

                  Response.Redirect("login.aspx", false);
              }
              else
              {
          

          Response.Write(@"<script> alert('Invalid Data has been Entered');</script>");

          Now if the value is 1, then it should Display the Message and after the Message has been Clicked it should move to the login Page. Now my Problem is that it moves to the Login Page without a Alert Message being Displayed And the send Alert for invalid Entry, will not show anythingm, there is a Warning sign on my Page at the Bootom left of my Page. What is wrong with my Javascript Thanks

          Vuyiswa Maseko, Sorrow is Better than Laughter, it may Sadden your Face, but It sharpens your Understanding VB.NET/SQL7/2000/2005 http://vuyiswamb.007ihost.com http://Ecadre.007ihost.com vuyiswam@tshwane.gov.za

          S Offline
          S Offline
          Sandeep Akhare
          wrote on last edited by
          #4

          You can do in follwoing way if (Res == 1) { this.ClientScript.RegisterStartupScript(this.GetType(), "key", "myfunction();", true); ) and in myfunction function just show the alert message and redirect user to Login Page <script type="text/javascript"> function myfunction() { alert('You have Successfully Registred') window.location.href='Login.aspx'; } </script>

          Thanks and Regards Sandeep If If you look at what you do not have in life, you don't have anything, If you look at what you have in life, you have everything... " Check My Blog

          V 1 Reply Last reply
          0
          • S Sandeep Akhare

            You can do in follwoing way if (Res == 1) { this.ClientScript.RegisterStartupScript(this.GetType(), "key", "myfunction();", true); ) and in myfunction function just show the alert message and redirect user to Login Page <script type="text/javascript"> function myfunction() { alert('You have Successfully Registred') window.location.href='Login.aspx'; } </script>

            Thanks and Regards Sandeep If If you look at what you do not have in life, you don't have anything, If you look at what you have in life, you have everything... " Check My Blog

            V Offline
            V Offline
            Vimalsoft Pty Ltd
            wrote on last edited by
            #5

            hi Thank you , its working

            Vuyiswa Maseko, Sorrow is Better than Laughter, it may Sadden your Face, but It sharpens your Understanding VB.NET/SQL7/2000/2005 http://vuyiswamb.007ihost.com http://Ecadre.007ihost.com vuyiswam@tshwane.gov.za

            1 Reply Last reply
            0
            • N ncsubbu

              Page.RegisterStartupScript("hai", "alert('hai')") the above display alert box

              your's subbu

              V Offline
              V Offline
              Vimalsoft Pty Ltd
              wrote on last edited by
              #6

              Thanks it works

              Vuyiswa Maseko, Sorrow is Better than Laughter, it may Sadden your Face, but It sharpens your Understanding VB.NET/SQL7/2000/2005 http://vuyiswamb.007ihost.com http://Ecadre.007ihost.com vuyiswam@tshwane.gov.za

              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