Solved

ClientScript.RegisterClientScriptBlock -redirect dont works in firefox?

Posted on 2007-11-18
5
1,851 Views
Last Modified: 2012-06-27
I have a frames based page, and need to make a redirect out of the frameset. I read that this could be done with javascript "top.location.href". It works fine in IE 7.0, but when testing it in Firefox it dont redirect at all (the browser has javascript enabled).

------------------------------------------------------------
This works in IE 7, but not in Firefox:
------------------------------------------------------------
string redirectUrl = "/view.aspx?id=" + Content.Id + "&newId=" + Content.Id;
Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "Redirect", "top.location.href('" + redirectUrl + "');", true);

------------------------------------------------------------
I tried this also, but it only works in IE 7:
------------------------------------------------------------
string redirectUrl = "/view.aspx?id=" + Content.Id + "&newId=" + Content.Id;
Response.Write("<script language='javascript'>top.location.href('" + redirectUrl + "');</script>");


Why does it not work in Firefox?? Thanks :)
0
Comment
Question by:webressurs
  • 2
  • 2
5 Comments
 
LVL 29

Accepted Solution

by:
Göran Andersson earned 500 total points
ID: 20309204
href is a property, not a method.
string redirectUrl = "/view.aspx?id=" + Content.Id + "&newId=" + Content.Id;
Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "Redirect", "top.location.href='" + redirectUrl + "';", true);

Open in new window

0
 
LVL 37

Expert Comment

by:samtran0331
ID: 20309360
since you're trying to redirect the page after the code executes, there's really no need to use javascript, you can redirect from the codebehind with:

Response.Redirect("view.aspx?id=" + Content.Id + "&newId=" + Content.Id);

instead of RegisterClientScriptBlock
0
 
LVL 29

Expert Comment

by:Göran Andersson
ID: 20309804
samtran0331, read the first sentence of the question.

Response.Redirect can only be used to do a redirect in the same frame.
0
 
LVL 1

Author Comment

by:webressurs
ID: 20310434
Hi! As GreenGhost say Response.Redirect can only be used to do a redirect in the same frame. Thats why I need to use a javascript fro doing this. Thank you GreenGhost , it worked perfect in IE and Firefox :)
0
 
LVL 1

Author Closing Comment

by:webressurs
ID: 31409835
Just what I needed!
0

Featured Post

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question