Adsence750x90

Monday, July 7, 2008

How to pass query string in Asp.net

How to pass query string in asp.net

we can pass query messages from one page(WebForm) to another in asp.net. for example
there are two pages page1.aspx and page2.aspx we want to pass some string values to page2.aspx.
then we can write

C# code
Response.Redirect("page2.aspx?msg=Hello");

this msg is query string "Hello" is passed to page2.aspx.
how can we retire this message from page2.aspx?
we can write
C# code
if (Request.QueryString["msg"] != null)
{
string message = Request.QueryString["msg"];
Response.Write(message);
}

No comments: