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

i want particular value from a url like below example

response=1&responsetext=SUCCESS&authcode=123478756&transactionid=6667666&avsresponse=&cvvresponse=&orderid=&type=sale&response_code=17800&amount=00&amount_authorized=00.00&surcharge=0.00

in this link i want "Success" and "2699489421" value how cant i get

thanks
Posted
Updated 2-Jun-15 1:25am
v3
Comments
aarif moh shaikh 2-Jun-15 8:27am    
Where "2699489421" ???

C#
if(Request.QueryString["responsetext"]!=null)
{
 string responseText = Request.QueryString["responsetext"].ToString();
}


similarly for transactionid use
C#
Request.QueryString["transactionid"].ToString()


If you are sending these via POST method then it will be

C#
Request.Form["transactionid"].ToString()
 
Share this answer
 
Use Javascript for it

JavaScript
function getParameterByName(name) {
    name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
    var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
        results = regex.exec(location.search);
    return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
}


call this function:

JavaScript
var responseText= getParameterByName('responsetext');
var transactionId= getParameterByName('transactionid');
 
Share this answer
 
Loads of ways: if you are in the page you can retrieve them via the Request.QueryString collection: Passing variables between pages using QueryString[^] shows examples.

If you just have the raw string and want to extract them, then either split the string on the ampersand:
C#
string[] keyValuePairs = input.Split('&');

And then split each of those on the equals sign and compare the strings:
C#
foreach (string kvp in keyValuePairs)
    {
    string[] kv = kvp.Split('=');
    if (kv.Length == 2)
        {
        switch (kv[0].ToLower())
            {
            case "responsetext":
                Console.WriteLine("Response: {0}", kv[1]);
                break;
            case "authcode":
                Console.WriteLine("Auth    : {0]", kv[1]);
                break;
            }
        }
    }
Or you could use a regex:
((?<Resp>(?<=responsetext=).*?)|(?<Auth>(?<=authcode=).*?))(&|$)
 
Share this answer
 

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