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. Java Script doesn't run before server.transfer

Java Script doesn't run before server.transfer

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

    I am using a javascript alert as a msgbox temp = " alert ('Login Required'); " page.registerstartupscript("login",temp) script works fine until I add server.transfer("login.aspx") the transfer works and the script doesn't execute Any Ideas on how to force the script to run first then the transfer

    Z T 2 Replies Last reply
    0
    • M mtm88001

      I am using a javascript alert as a msgbox temp = " alert ('Login Required'); " page.registerstartupscript("login",temp) script works fine until I add server.transfer("login.aspx") the transfer works and the script doesn't execute Any Ideas on how to force the script to run first then the transfer

      Z Offline
      Z Offline
      zzq9624
      wrote on last edited by
      #2

      try this temp = " alert ('Login Required'); window.location='Login.aspx'" i love dotnet !

      M 1 Reply Last reply
      0
      • Z zzq9624

        try this temp = " alert ('Login Required'); window.location='Login.aspx'" i love dotnet !

        M Offline
        M Offline
        mtm88001
        wrote on last edited by
        #3

        You da man. After six hours of google, 100's of attempts at different code I find salvation. Thanks

        1 Reply Last reply
        0
        • M mtm88001

          I am using a javascript alert as a msgbox temp = " alert ('Login Required'); " page.registerstartupscript("login",temp) script works fine until I add server.transfer("login.aspx") the transfer works and the script doesn't execute Any Ideas on how to force the script to run first then the transfer

          T Offline
          T Offline
          Tomas Petricek
          wrote on last edited by
          #4

          Hi, unfortunately this can't work, because when you call Server.Transfer, response stream is cleared. If you want to show page "login.aspx" with this client-side script, you must generate client side script from that web form. You can use query string for this:

          Server.Transfer("login.aspx?showalert=true");

          And in login.aspx:

          if (Request.QueryString["showalert"]="true")
          {
          string temp="<script language="javascript"> alert ('Login Required');</script>"
          Page.RegisterStartupScript("login",temp);
          }

          Tomáš Petříček (Microsoft C# MVP)
          www.eeeksoft.net | Asp.Net Graphical controls

          M 1 Reply Last reply
          0
          • T Tomas Petricek

            Hi, unfortunately this can't work, because when you call Server.Transfer, response stream is cleared. If you want to show page "login.aspx" with this client-side script, you must generate client side script from that web form. You can use query string for this:

            Server.Transfer("login.aspx?showalert=true");

            And in login.aspx:

            if (Request.QueryString["showalert"]="true")
            {
            string temp="<script language="javascript"> alert ('Login Required');</script>"
            Page.RegisterStartupScript("login",temp);
            }

            Tomáš Petříček (Microsoft C# MVP)
            www.eeeksoft.net | Asp.Net Graphical controls

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

            Thanks for the code.:-O

            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