Aspdotnet-Suresh

aspdotnet-suresh offers C#.net articles and tutorials,csharp dot net,asp.net articles and tutorials,VB.NET Articles,Gridview articles,code examples of asp.net 2.0 /3.5,AJAX,SQL Server Articles,examples of .net technologies

Get URL Parameters using jQuery | Get Parameter Values From URL in jQuery

Feb 1, 2013
Introduction

Here I will explain how to get url parameters using jQuery or get url parameters values using JavaScript in asp.net

Description:
  
In previous articles I explained jQuery get current page url and title, jQuery disable future dates in datepicker, jQuery Get Cursor position, jQuery Bind double click event to button control, jQuery create rounded corners for textbox and many articles relating to
JavaScript, jQuery, asp.net. Now I will explain how to get url parameters using jQuery or get url parameters values using JavaScript in asp.net.

To implement this we need to write the code like as shown below


<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>
Demo

To check above example I given ur like “http://aspdotnet-suresh.com/test.aspx?username=suresh&userid=2” and it return values like as shown below 

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 RSS subscribe by email Subscribe by Email

1 comments :

Unknown said...

How to create pager in data list can you give me some example i am waiting of your response

Give your Valuable Comments

Note: Only a member of this blog may post a comment.

© 2015 Aspdotnet-Suresh.com. All Rights Reserved.
The content is copyrighted to Suresh Dasari and may not be reproduced on other websites without permission from the owner.