Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP.NET
how ser querystring parameter in c#?
Posted 9-Jan-13 21:23pm
ExpertITM1.2K
Comments
Rai Pawan at 10-Jan-13 2:31am
   
Please use proper grammar to mention your question in English. - Pawan
jibesh at 10-Jan-13 2:43am
   
What do you mean by "ser"
OriginalGriff at 10-Jan-13 3:15am
   
This is not a good question - we cannot work out from that little what you are trying to do.
Remember that we can't see your screen, access your HDD, or read your mind.
Use the "Improve question" widget to edit your question and provide better information.
AshishChaudha at 10-Jan-13 3:46am
   
please explain your question properly.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

For details of how to pass and use query strings, look here:
Passing variables between pages using QueryString[^]
How to use Querystring[^]

Post specific issue if you face.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Hi,

While you post a question please be given proper information.
I think your asking the query string values.

please read the follwing links for better understading about the query string.

Passing variables between pages using QueryString[^]
http://msdn.microsoft.com/en-us/library/6c3yckfw(v=vs.100).aspx[^]
http://www.dotnetperls.com/querystring[^]
http://www.aspdotnet-suresh.com/2012/10/aspnet-pass-multiple-parameters-in.html[^]

please check with this links , this links might be help for you...
  Permalink  
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

the query string can be passed by using the following format
public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        String id="123";
        String name = "hello";
 
        Response.Redirect("Default2.aspx?id="+id+"&name="+name);
    }
}
don't allow spaces between '&' symbol and other parameter
you can use this inside buttonclick function or any other function

To retrive the value of the query string in next page use the following in page load
public partial class Default2 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        string m = Request.QueryString["id"].ToString();
        string n = Request.QueryString["name"].ToString();
        Response.Write(m + " " + n);
    }
}
  Permalink  
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 5

Hi User/Guest,

Please Explain your Exact Requirement of QueryString. So I Can Provide Best Answer for your Requirement. Basically QueryString use in Get Method of Http For Sending Small Amount of Data to the Server and With Public Visibility.
So In General Way,

Eg.of Query String :

Response.Redirect("Default2.aspx?id="+id+"&name="+name);


In This Example You are Requested Web Page 'Default2.aspx' from Server.
? :- Denote that URL contain the Query String.
After '?' You Add Value Pair just like Name=Rahul

and you separate your multiple value pair by & Sign by Ending Each Value Pair.
Just Like in Example
id : Variable Name,
+ : Concatenate with URL and variable,
& : Multiple Value pair in the URL.

Full Example : Response.Redirect("Default2.aspx?ID=437&Name=Rahul Kumar&ContactNo=7428323290");

So You Can Add Multiple Value-Pair in URL by Separating with '&' Sign.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

protected internal T ParseQueryStringValue<T>(string key, string value)
  {
      if (!string.IsNullOrEmpty(value))
      {
          //TODO: Map other common QueryString parameters type ...
          if (typeof(T) == typeof(string))
          {
              return (T)Convert.ChangeType(value, typeof(T));
          }
          if (typeof(T) == typeof(int))
          {
              int tempValue;
              if (!int.TryParse(value, out tempValue))
              {
                  throw new ApplicationException(string.Format("Invalid QueryString parameter {0}. The value " +
                                                            "'{1}' is not a valid {2} type.", key, value, "int"));
              }
              return (T)Convert.ChangeType(tempValue, typeof(T));
          }
          if (typeof(T) == typeof(DateTime))
          {
              DateTime tempValue;
              if (!DateTime.TryParse(value, out tempValue))
              {
                  throw new ApplicationException(string.Format("Invalid QueryString parameter {0}. The value " +
                                                       "'{1}' is not a valid {2} type.", key, value, "DateTime"));
              }
              return (T)Convert.ChangeType(tempValue, typeof(T));
          }
      }
      return default(T);
  }
  Permalink  
Comments
Marcus Kramer at 10-Jan-13 10:17am
   
Plagiarized from here
jibesh at 10-Jan-13 12:35pm
   
my 5 for your findings :) he should mention the link atleast. good job again

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sascha Lefévre 485
1 Sergey Alexandrovich Kryukov 325
2 Maciej Los 240
3 Abhinav S 164
4 Peter Leow 120
0 Sergey Alexandrovich Kryukov 6,953
1 OriginalGriff 6,311
2 Maciej Los 2,732
3 Peter Leow 2,674
4 Abhinav S 2,562


Advertise | Privacy | Mobile
Web04 | 2.8.150414.1 | Last Updated 10 Jan 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100