Click here to Skip to main content
15,895,746 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
When using javascript:location.replace with Hyperlink.NavigateUrl it works perfectly.
For instance, this works great:
HyperLinks.NavigateUrl = "javascript:location.replace('step3.aspx?Time=" & i & "');"
This doesn't work at all:
Response.Redirect("javascript:location.replace('step3.aspx?Time=" & i & "'); return false;")
It appears to just be just posting back to itself or doing nothing.
What's the proper syntax I should be using or, is there an alternative?

What I have tried:

'This I've tried and it works
HyperLinks.NavigateUrl = "javascript:location.replace('step3.aspx?Time=" & i & "');"

'This I've tried and it doesn't work
Response.Redirect("javascript:location.replace('step3.aspx?Time=" & i & "'); return false;")
Posted
Updated 10-Oct-17 7:26am
v3

1 solution

If you want to redirect to a new page, then just redirect to that page:
Response.Redirect("step3.aspx?Time=" & i)

If you want to replace the current page in the browser's history, you'll have to do that from Javascript on the client. By the time your server-side code executes, it's too late to do that.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900