Solved

Using JavaScript to goto another aspx in ASP.NET

Posted on 2008-10-06
3
368 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:
adilkhan 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:adilkhan
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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
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…

760 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

21 Experts available now in Live!

Get 1:1 Help Now