Showing posts with label Query String. Show all posts
Showing posts with label Query String. Show all posts

Sunday, 22 December 2013

Query String

Interview Questions & Answer on ASP.NET Query Strings

Q : Give an example of using querystrings to send data from one page to another?
Ans : Query strings are a very simple and popular technique to pass data from one Web page to the next. You send data as part of the URL. In the below example FName and LName are sent as part of the URL. In the page load of QueryStrings2.aspx we use Request.QueryString to read the values. As we are sending more than one query string we use the & symbol to seperate query strings.
Q : //Code to send query strings FName and LName as part of the URL
Ans : QueryStrings2.aspx?FName=David&LName=Boon
protected void Page_Load(object sender, EventArgs e)
{
//Code to read Query String values
string FirstName = Request.QueryString["FName"];
string LastName = Request.QueryString["LName"];
Response.Write("Data from QueryStrings1.aspx : " + FirstName + ", " + LastName);
}
Q : Give an example to send Query Strings from code?
Ans : You can send query strings from server side code using the Response.Redirect() method as shown below.
Response.Redirect("QueryStrings2.aspx?FName=David&LName=Boon");
Q : What are the advantages of using Query Strings?
Ans : 1. Query strings are easy to implement.
2. Browser support for passing values in a query string is nearly universal.
3. Query strings are contained in the HTTP request for a specific URL and do not require server resources.
Q : What are the disadvantages of using querystrings to send data from one page to another?
Ans : 1. Query strings are insecure because the information in the query string is directly visible to the user on the address line in the browser.
2. Many browsers impose a 255 URL character limit which can limit their flexibility.

C# program Selection Sorting

Selection sort is a straightforward sorting algorithm. This algorithm search for the smallest number in the elements array and then swap i...