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. General Programming
  3. C#
  4. Response.Redirect is not working.. a peculiar problem..One solution found !!

Response.Redirect is not working.. a peculiar problem..One solution found !!

Scheduled Pinned Locked Moved C#
sysadminhelpquestion
2 Posts 2 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.
  • P Offline
    P Offline
    PhaniKatakam
    wrote on last edited by
    #1

    I would like to share a solution with all of you guys to the Response.Redirect problem. I have a scenario: 1. An asp page containing two submit type buttons 'Back' and 'Save'. 2. Save may do some action and stay in the same page.. 3. But Back would do same as save button..but Goes to Home Page. 4. U may have Save_Click () serverside code in aspx.cs 5. U can simulate the same from back.. and also hidBack to maintain from which button its coming from... function ClickBack() { document.Form1.hidBack.value = "YES"; document.Form1.Button1.click(); //IMPORTANT:: RETURN FALSE TO NULLIFY POSTING BY BACK BUTTON. return false; } 6. Server side code may look as private void Save_Click(object sender, System.EventArgs e) { if(Request.Form["hidBack"] == "YES") { Page.Response.Redirect("Home.aspx",false); } Response.Write(" U pressed first Button"); } 7.if WE DONT HAVE //IMPORTANT:: code line, it will postback twice to the server..there by Response.Redirect doesnt work. 8. Any other observations?? thanks Phani, Virtusa.

    H 1 Reply Last reply
    0
    • P PhaniKatakam

      I would like to share a solution with all of you guys to the Response.Redirect problem. I have a scenario: 1. An asp page containing two submit type buttons 'Back' and 'Save'. 2. Save may do some action and stay in the same page.. 3. But Back would do same as save button..but Goes to Home Page. 4. U may have Save_Click () serverside code in aspx.cs 5. U can simulate the same from back.. and also hidBack to maintain from which button its coming from... function ClickBack() { document.Form1.hidBack.value = "YES"; document.Form1.Button1.click(); //IMPORTANT:: RETURN FALSE TO NULLIFY POSTING BY BACK BUTTON. return false; } 6. Server side code may look as private void Save_Click(object sender, System.EventArgs e) { if(Request.Form["hidBack"] == "YES") { Page.Response.Redirect("Home.aspx",false); } Response.Write(" U pressed first Button"); } 7.if WE DONT HAVE //IMPORTANT:: code line, it will postback twice to the server..there by Response.Redirect doesnt work. 8. Any other observations?? thanks Phani, Virtusa.

      H Offline
      H Offline
      Heath Stewart
      wrote on last edited by
      #2

      This question belongs in the ASP.NET forum.

      Microsoft MVP, Visual C# My Articles

      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