How to post back to a particular page using JavaScript

Posted on 2012-08-28
Last Modified: 2012-09-03
I am using with Java Script.

I have a java script method in my master page named "search".
When search is called I display a popup window. When that window
closes, I would like to transfer the user to a specific
page. Let's call that page "default.aspx"

So how do I transfer to the default.aspx page using Java script? This
would probably be done at line 6 below, but I don't know how to do it.

Note that if search is performed 50 times, I don't want 50 default.apx
windows open. I just want one default.aspx window open.

So somehow I need to always post back to "default.aspx"

1  <script type="text/javascript">
3 function search()
4 {
5      window.showModalDialog("PopupPage.aspx")

Question by:brgdotnet
    LVL 49

    Accepted Solution

    When you close your modal dialog do as follows
    window.location = "default.aspx";

    Open in new window

    Although I am not certain this is what you want. You have left some gaps in your description so subject to misinterpretation.
    If I read between the lines it sounds like you want the dialog to capture search criteria and you want to post these back to default.aspx.

    The way your question is phrased it sounds like you just want to  send the user to another page - in which case window.location is the way to do that.

    If you actually want to post something back you have to populate some form variables with jscript and then invoke the postback action on the page.
    LVL 16

    Assisted Solution

    by:Imran Javed Zia
    LVL 2

    Author Closing Comment

    Thank you

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Find Ransomware Secrets With All-Source Analysis

    Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

    Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
    A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
    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…

    761 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

    8 Experts available now in Live!

    Get 1:1 Help Now