How to Get URL Parameters or Query String Value using JQuery in Asp.Net C# VB.Net

Query String is used to transfer data from one page to another page. Here in this example I will explain How one can get URL Parameters or Query String Value using JQuery from client side. In this example I will manually pass URL parameters or Query string to Default.aspx page & from that page I will retrieve values using JQuery. So that you can apply the same technique whenever required.

Related Article:
How to Get URL Parameters or Query String Value using Javascript in Asp.Net C# VB.Net

Objective/Outcome:
How to Get URL Parameters or Query String Value using jQuery in Asp.Net Csharp VB.Net

To do the Example add a Label Control First:

<asp:Label ID="Label1" runat="server" Text=""></asp:Label>

JQuery Code Example to get URL Parameter or Query String Value:

<script type="text/javascript">
    $(document).ready(function () {
        var s_Current_Page_URL = window.location.search.substring(1);
        var sQueryStrings = s_Current_Page_URL.split('&');
        for (var i = 0; i < sQueryStrings.length; i++) {
            var sQueryStringParameters = sQueryStrings[i].split('=');
            if (sQueryStringParameters.length > 1)
                $('#<%= Label1.ClientID %>').html($('#<%= Label1.ClientID %>').text() + '<br/>' + sQueryStringParameters[0] + ' = ' + sQueryStringParameters[1]);
        }
    });  
</script>

Hope now you can read URL Parameter or Query String Values from client side using JQuery.

Download Code Example C#        Download Code Example VB.Net

Leave a Reply

Your email address will not be published. Required fields are marked *

AlphaOmega Captcha Classica  –  Enter Security Code