Page 1 of 1

How to pass parameters to JavaScript from scripting page?

Posted: Sat Mar 27, 2010 10:43 pm
by Neofriend
using ASP.NET C# please :)

Re: How to pass parameters to JavaScript from scripting page?

Posted: Sun Mar 28, 2010 12:24 am
by Neo
Parameters are passed to the server side and JavaScript runs in the client side and it is an interesting topic on how to do it. See following sample ASP.Net code. Note that the long and lat variables are set from the parameters that are passed to the ASP page (I assume there are two parameters named long and lat are passed to ASP page).

Code: Select all

<html>
<head>
<script type="text/javascript">
function myFunction(){

        var long = <% Response.Write(Request.QueryString("long")) %>;
        var lat = <% Response.Write(Request.QueryString("lat")) %>;

        alert("long " + long + " lat " + lat);
}
</script>
</head>

<body>

<!-- HTML Page code goes here -->

</body>
</html>
Enjoy!