Solved

ClientScript.RegisterClientScriptBlock -redirect dont works in firefox?

Posted on 2007-11-18
5
1,846 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
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…

706 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now