How to pass information between pages?

 Posted by deccansoft on 10/30/2010 | Category: ASP.NET Interview questions | Views: 1234

Out of many choices one choice is to make use of Query String property of Request object, which allows us to pass information between pages. For example to pass information: Response.Redirect(“Newpage.aspx?Name=”+txtName.Text +”&Age=”+txtAge.Text); To Retrieve information: String name=Request.QueryString[“Name”]; String age=Request.QueryString[“Age”]; Advantages: 1. It is easy to use and is light weight. DisAdvantages: 1. It has Max length of 1or 2 kb ,so limited information can be passed. 2. It is visible in address part of the browser and hence we cannot send any sensitive information. 3. QueryString cannot be used to send ‘ &’ and ‘space’ characters. To solve this problem we have to use Server.UrlEncode. For example above code can be rewritten as: Response.Redirect(“Newpage.aspx?Name=”+Server.UrlEncode(txtName.Text )+”&Age=”+Server.UrlEncode(txtAge.Text));

Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response