In previous articles I explained jQuery get current page url and title, jQuery change textbox background color on focus, jQuery Enable or disable textbox controls, jQuery create rounded corners for textbox, and many articles relating to JavaScript, jQuery, asp.net. Now I will explain how to get query string parameter values using jQuery in asp.net.
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>jQuery
Get Current Page Url Parameter values</title>
<script type="text/javascript"
src="http://code.jquery.com/jquery-1.8.2.js"></script>
<script type="text/javascript">
$(function ()
{
var name = GetParameterValues('username');
var id = GetParameterValues('userid');
$('#spn_UserName').html('<strong>' + name + '</strong>');
$('#spn_UserId').html('<strong>' + id + '</strong>');
});
function GetParameterValues(param) {
var url =
window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
for (var i = 0; i <
url.length; i++) {
var urlparam = url[i].split('=');
if (urlparam[0] == param) {
return urlparam[1];
}
}
}
</script>
</head>
<body>
<form id="form1"
runat="server">
<div>
<p>UserName:
<span id="spn_UserName"></span></p>
<p>UserId:
<span id="spn_UserId"></span></p>
</div>
</form>
</body>
</html>
|
|
If you enjoyed this post, please support the blog below. It's FREE! Get the latest Asp.net, C#.net, VB.NET, jQuery, Plugins & Code Snippets for FREE by subscribing to our Facebook, Twitter, RSS feed, or by email. |
|||
Subscribe by RSS
Subscribe by Email
|
|||
|
|
|

Subscribe by RSS
Subscribe by Email
4 comments :
how can i add data pager in data list
sir can u please post the article for upload video and play in browser !!
Thanks
Hello Sir,
i am facing a problem when i was calling a Webservice using JQuery AJax (With Input)
The Error is 500 internal server error.
Please help me
Thnx in Advance