location.replace

B

brian

Is there a way to use location.replace in code behind?

The code below will work for a window.alert but not for
location.replace.

For example:

Private Sub Page_Load(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles MyBase.Load

Button1.Attributes.Add("onclick", "window.alert
('Hello');") ' this works


Button1.Attributes.Add("onclick", "location.replace
('test2.aspx');") ' this doesn't

End Sub

I want to prevent the user from going back to test1.aspx
after executing server-side code. I know this will work
if I use a javascript function on the client side but then
it won't process my server-side code.
 
A

Alexey Kouzmitch

I think that

Server.Transfer
or
Response.Redirect

is what you are looking for.
 
G

Guest

Neither server.transfer or response.redirect prevents the
user from returning to the originating page.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top