Solved

Using JavaScript to goto another aspx in ASP.NET

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

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…
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…

864 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

22 Experts available now in Live!

Get 1:1 Help Now