Solved

ClientScript.RegisterClientScriptBlock -redirect dont works in firefox?

Posted on 2007-11-18
5
1,861 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
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 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…

717 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