PROBLEM IN PASSING VALUE FROM ONE PAGE TO OTHER PAGE IN ASP.NET

John Smith

Total Post:103

Points:727
Posted by  John Smith
C# 
C#
 2505  View(s)
Ratings:
Rate this:
Hi,
Could you please let me know how to pass value from one page to other through Query String as I am new in ASP.NET.
Your help will be appreciated!

Thanks,
John
  1. Amit Singh

    Post:103

    Points:721
    Re: Problem in passing value from one page to other page in ASP.NET

    We pass the value from one page to another page by query string, we write the syntax as

    1) Response.Redirect("Default.aspx?query=John Smith");

    where "query" is query string variable and "John Smith" is the string value for query variable.
    Now we access the value on Default.aspx page as

    string query=Request.QueryString["query"].toString();

    2) we pass the multiple parameter by query string then we write the syntax as

    Response.Redirect("Default.aspx?query1=John Smith &query2=krish");

    Now we access the value on Default.aspx page as

    string query1=Request.QueryString["query1"].toString();
    string query2=Request.QueryString["query2"].toString();


    or
    string query1=Request.QueryString[0].toString();
    string query2=Request.QueryString[1].toString();


    or
    string query1=Request.Params[0].toString();
    string query2=Request.Params[1].toString();


    3) We pass the any value by query string as

    string str="JohnSmith";
    Response.Redirect("Default.aspx?query="+str);


    And access these value on another page by

    string query=Request.QueryString["query"].toString();

      Modified On Sep-29-2010 09:46:11 AM
  1. Alex R

    Post:40

    Points:280
    Re: Problem in passing value from one page to other page in ASP.NET

    If you want to pass value from one page to another using Query string then just add name of query followed by its value.

    example

    supose you have two pages a.aspx and b.aspx and you want to pass value from a.aspx to b.aspx then instead of just redirecting to page b.aspx, redirect to b.aspx as b.aspx?Name=Haider

    Here Name is name of Query String and Haider is value you want to pass.

    Now to access this value in b.aspx use

    string strName = Request.QueryString["Name"].toString();

  1. John Smith

    Post:103

    Points:727
    Re: Re: Problem in passing value from one page to other page in ASP.NET

    thx for your time ..:)

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!