• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 281
  • Last Modified:

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

0
doramail05
Asked:
doramail05
1 Solution
 
Hamid HassanCommented:
use
public NameValueCollection QueryString = new NameValueCollection();

instead of
public NameValueCollection QueryString { get; }
0
 
doramail05Author Commented:
cannot, pointing to namevaluecollection in both

public NameValueCollection QueryString = new NameValueCollection();
0
 
Ajay SharmaCommented:
import the import System.Collections.Specialized namespace like below

using System.Collections.Specialized;
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now