Solved

Using JavaScript to goto another aspx in ASP.NET

Posted on 2008-10-06
3
370 Views
Last Modified: 2012-05-05
Hello,

Using JavaScript I'd live to redicted my user to a difference aspx page in my ASP.NET 2.0 project within the same browser window.  Currently I have:

var oForm = document.forms[0];
oForm.action =  "Report.aspx?ReportType=" + reportType;

But that open a new browser.  I'd like this to be in the same browser.

Thanks
0
Comment
Question by:eshurak
  • 2
3 Comments
 
LVL 23

Accepted Solution

by:
Saqib Khan earned 500 total points
ID: 22652466
var oForm = document.forms[0];
oForm.action =  "Report.aspx?ReportType=" + reportType;
oForm.submit()  <--- Did you try this to submit?

Another way to do is is.

document.location = "Report.aspx?ReportType=" + reportType;

You can do above within the onClick event of a button (Client Side onClick)


0
 
LVL 3

Author Comment

by:eshurak
ID: 22652658
Thanks for your response.  I did not write this code so I'm not sure what's going on.

I left out the submit part.

                oForm.target = '_reportWin';
                oForm.submit();

If I comment out the target it stays in the same browser and I'm pretty happy with that.  I tried document.location but it gives me an error message so I'll stick with the oForm method.
0
 
LVL 23

Expert Comment

by:Saqib Khan
ID: 22652681
> oForm.target = '_reportWin';
in you orignal post you did not mention "target" line, target will open form in a new window. and yes that was the problem.
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
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…

776 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