Hi ,
We all are familiar with Query string in asp.net.Today I'm showing query string handling with JavaScript .
To sent the data to another page i create a function on page1.aspx and call the function on client-side button click
<script type="text/javascript" language="javascript">
function PassQuery()// my fuction
{
var paramVal1 = "SimplyAsp.net";
var paramVal2 = "simplyasp.blogspot.com";
window.open("Page2.aspx?id=" + paramVal1 + "&p=" + paramVal2);
}
</script>
function PassQuery()// my fuction
{
var paramVal1 = "SimplyAsp.net";
var paramVal2 = "simplyasp.blogspot.com";
window.open("Page2.aspx?id=" + paramVal1 + "&p=" + paramVal2);
}
</script>
To retrieve the value i call another function on body load of page2.aspx
<script language="javascript" type="text/javascript">
function GetQueryValue()
{
var query = window.location.search.substring(1);
var parms = query.split('&');
for (var i = 0; i < parms.length; i++) {
var pos = parms[i].indexOf('=');
if (pos > 0) {
var key = parms[i].substring(0, pos);
var val = parms[i].substring(pos + 1);
alert(val);
}
}
}
</script>
function GetQueryValue()
{
var query = window.location.search.substring(1);
var parms = query.split('&');
for (var i = 0; i < parms.length; i++) {
var pos = parms[i].indexOf('=');
if (pos > 0) {
var key = parms[i].substring(0, pos);
var val = parms[i].substring(pos + 1);
alert(val);
}
}
}
</script>
Hope it help u some way's
Have a nice day... 'N happy Coding :)
No comments:
Post a Comment