Link to home
Start Free TrialLog in
Avatar of doramail05
doramail05Flag for Malaysia

asked on

Getting all querystrings

i try to get all querystring with

 public NameValueCollection QueryString { get; }  

but have error on 'NameValueCollection' in both,

NameValueCollection coll=Request.QueryString;
namespace BlankRoom
{
    public NameValueCollection QueryString { get; }    

    public partial class blankajax : System.Web.UI.Page
    {
       

        protected void Page_Load(object sender, EventArgs e)
        {
            int loop1, loop2;

            // Load NameValueCollection object.
            NameValueCollection coll=Request.QueryString; 
            // Get names of all keys into a string array.
            String[] arr1 = coll.AllKeys; 
            for (loop1 = 0; loop1 < arr1.Length; loop1++) 
            {
               Response.Write("Key: " + Server.HtmlEncode(arr1[loop1]) + "<br>");
               String[] arr2 = coll.GetValues(arr1[loop1]);
               for (loop2 = 0; loop2 < arr2.Length; loop2++) 
               {
                  Response.Write("Value " + loop2 + ": " + Server.HtmlEncode(arr2[loop2]) + "<br>");
               }
            }

        }

Open in new window

Avatar of Hamid Hassan
Hamid Hassan
Flag of Pakistan image

use
public NameValueCollection QueryString = new NameValueCollection();

instead of
public NameValueCollection QueryString { get; }
Avatar of doramail05

ASKER

cannot, pointing to namevaluecollection in both

public NameValueCollection QueryString = new NameValueCollection();
ASKER CERTIFIED SOLUTION
Avatar of Ajay Sharma
Ajay Sharma
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