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
Solved

Using JavaScript to goto another aspx in ASP.NET

Posted on 2008-10-06
3
371 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
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…

860 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