Solved

query string javascript

Posted on 2011-02-28
7
467 Views
Last Modified: 2012-05-11
My page APS gets passed a query string and the request it like this

Request.QueryString("Product_ID")

Now, in the following javascript procedure how would i pass this this query string to the PopupForm.aspx form that is being opened?

  function OpenChild() {

        var WinSettings = "center:yes;resizable:no;dialogHeight:300px"
        // ALTER BELOW LINE - supply correct URL for Child Form
        var MyArgs = window.showModalDialog("../PopupForm.aspx", MyArgs, WinSettings);

    }
0
Comment
Question by:vbnetcoder
  • 3
  • 3
7 Comments
 
LVL 82

Expert Comment

by:leakim971
ID: 35000221
try :

function OpenChild() {

        var WinSettings = "center:yes;resizable:no;dialogHeight:300px"
        // ALTER BELOW LINE - supply correct URL for Child Form
        var pid = "1234";
        var MyArgs = window.showModalDialog("../PopupForm.aspx?Product_ID=" + pid, MyArgs, WinSettings);

    }

Open in new window

0
 

Author Comment

by:vbnetcoder
ID: 35000337
OK the passing to the new form works find but how do i get the value of product_ID that was passed to the form?
0
 
LVL 29

Accepted Solution

by:
Paul Jackson earned 500 total points
ID: 35000393
Put this in your page to defiine a javascript variable that can be used in the function:
<% Response.write("<script language='javascript'>var prodid = " & Request.QueryString("Product_ID") & ";</script>")%>

The use this variable to pass the product id as a querystring:
function OpenChild() {

        var WinSettings = "center:yes;resizable:no;dialogHeight:300px"
        // ALTER BELOW LINE - supply correct URL for Child Form
        var MyArgs = window.showModalDialog("../PopupForm.aspx?Product_ID="+ prodid, MyArgs, WinSettings);

    }
0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
LVL 29

Expert Comment

by:Paul Jackson
ID: 35000404
Request.Querystring("Product_ID") can then be used on the child form to get the product id
0
 

Author Comment

by:vbnetcoder
ID: 35000509
Where do i put this line of code that you gave me above:

<% Response.write("<script language='javascript'>var prodid = " & Request.QueryString("Product_ID") & ";</script>")%>



0
 
LVL 29

Expert Comment

by:Paul Jackson
ID: 35000568
Put it in your aspx page just above your javascript functions.
0
 

Author Closing Comment

by:vbnetcoder
ID: 35000601
ty
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

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…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
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…

821 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