Click here to Skip to main content
15,894,460 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
how ser querystring parameter in c#?
Posted
Comments
Rai Pawan 10-Jan-13 2:31am    
Please use proper grammar to mention your question in English. - Pawan
Jibesh 10-Jan-13 2:43am    
What do you mean by "ser"
OriginalGriff 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 10-Jan-13 3:46am    
please explain your question properly.

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.
 
Share this answer
 
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...
 
Share this answer
 
v2
the query string can be passed by using the following format
C#
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
C#
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);
    }
}
 
Share this answer
 
v2
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.
 
Share this answer
 
C#
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);
  }
 
Share this answer
 
Comments
fjdiewornncalwe 10-Jan-13 10:17am    
Plagiarized from here
Jibesh 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)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900