Click here to Skip to main content
15,891,184 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I am searching for a way to fetch a Query String Value from Query String. I found a method here

Link

But is this is the best way?

Thanks
Posted

Hello,

You can use this code in JQuery:

C#
$(document).ready(function(){
    var a=getParameterValue('b')
});

function getParameterValue(name)
{
    var querystring = location.search.replace('?', '').split('&');
    var ParamValue = ''
    $.each(querystring, function(i,q){
        if(q.split('=')[0] == name){
            ParamValue = q.split('=')[1];
        }
    });
    return ParamValue;
}
 
Share this answer
 
JavaScript
var url = "Card/Revenue";
url = url + '?ULtra=' + ULtra+ '&ROWID=' + RowID;


Card is the Action Name
Revenue is the Controller name

Call it like

C#
public ActionResult Card (string ULtra, int RowID)
 
Share this answer
 
v2
 
Share this answer
 
Comments
Arjun Menon U.K 7-Jul-14 11:18am    
Hi Nirav, thanks for the reply. Out of scope of this question. I have written the following JQuery in my ascx page and its a sharepoint webpart shown as pop up. But the alert is not coming


$(document).ready(function () {
memoID= GetQueryStringParams('MemoID');
alert(memoID);
});


function GetQueryStringParams(querystring)
{
try {
var pageURL = window.location.search.substring(1);
var queryStrings = pageURL.split('&');
for (var i = 0; i < queryStrings.length; i++)
{
var parameterName = queryStrings[i].split('=');
if (parameterName[0] == querystring)
{
return parameterName[1];
}
}
} catch (e) {
alert(e.message);
}
}​

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900