C# Web: how to use variable in query string

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • idioteque
    New Member
    • Nov 2007
    • 8

    #1

    C# Web: how to use variable in query string

    Trying to figure out what the syntax is to say that I'll except any result of a query value in a string. In the code below, for the first case statement, I want any number returned for "paging=" part of the url to work for that case statement.

    Thanks!

    Code:
    if((Request.ServerVariables["QUERY_STRING"] != null))
    {
    	switch(Request.ServerVariables["QUERY_STRING"])
    	{
    		case "Paging=WHAT DO I PUT HERE?":				
    				lnkto.NavigateUrl ="http://dev.xxxxx.com/TitleList.aspx?searchType=" +ms.SearchType.ToString() + "&categoryid=" + ms.SearchCategoryID.ToString() + "&searchText=&CategoryPrefer=tv&category=All";
    				lblto.Text = "View It worked Content";
    				break;
    		case "searchType=2&searchText=&CategoryID=":
    				lnkto.NavigateUrl = "http://dev.xxxxx.com/TitleList.aspx?searchType=2&CategoryPrefer=movies&searchText=&category=All";
    				lblto.Text = "View All Movies";
    				break;
    		default: lnkto.NavigateUrl ="http://dev.xxxxx.com/TitleList.aspx?searchType=4&searchText=&CategoryPrefer=tv&category=All";
    				lblto.Text = "View All Content";
    				break;		
    	}
    }
  • int08h
    New Member
    • Apr 2007
    • 28

    #2
    You can get the value through Request.QuerySt ring[key] where key is "Paging" in your case

    string str = Request.QuerySt ring["Paging"];
    switch (str)
    {
    //Add implementation
    }

    Comment

    • idioteque
      New Member
      • Nov 2007
      • 8

      #3
      Originally posted by int08h
      You can get the value through Request.QuerySt ring[key] where key is "Paging" in your case

      string str = Request.QuerySt ring["Paging"];
      switch (str)
      {
      //Add implementation
      }
      Hmm, it seems I can't use a case/switch setup with that though, because they don't accept variables.

      Comment

      Working...