Link to home
Start Free TrialLog in
Avatar of David C
David CFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Request.QueryString (sort of)

Hi Experts,

Is there a way to get the value of a variable given a label with text "rd=5&key=stock&c0=False" to use the same functionality as Request.QueryString("rd") but using the label instead?

Thanks
ASKER CERTIFIED SOLUTION
Avatar of Lokesh B R
Lokesh B R
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of David C

ASKER

Thanks very much, this is doing the job but I just took a snippet of the string. The actual string is much longer i.e. "a=Tom&b=Casey&rd=5&key=stock&c0=False&c1=False" so your code is only getting the first key and value
Hi,

In ForEach loop you get all the values.

string data = "a=Tom&b=Casey&rd=5&key=stock&c0=False&c1=False";
            string Key;
            string value;

            foreach (string val in data.Split('&'))
            {
                string[] values = val.Split('=');

                if (values[0] != null)
                    Key = values[0];

                if (values[1] != null)
                    value = values[1];

            }

Open in new window

Avatar of David C

ASKER

Excellent!