Topic: State - Query Strings
    
        
        
            
            
            
        
          
        
             
                    
        
                           
            
                
                    
    
        
    
    
        Query Strings
         
        Use these strings to pass information between requests and responses as part of the Web Address.
        Query strings are visible to the user, so they should not contain secure information such as passwords
         
        Query Strings allow you to send additional information along with an address. In HTML, query
        strings appear after a question mark in a hyperlink, as shown here:
         
        <A HREF="WebForm1.aspx?UName=Wombat">Query String sample.</A>
         
        To send a query string in code, add it to the address of a Redirect method. The following
        Click event procedure is equevalent to the preceding HTML:
         
        private void butSend_Click(object sender, System.EventArgs e)
        {
           // redisplay this page with a QueryString
           Response.Redirect(Request.FilePath + "?UName=Wombat");
        }
         
        To retrieve a query string in code, use the QueryString method of the Request object.
        The following code displays the UName item from the query string created in the 
        preceeding examples.
         
        private void Page_Load(object sender, System.EventArgs e)
        { 
           // Check for QueryString
           if (Request.QueryString["Uname"] != null)
           {   
              //Display message
              lblQstring.Text = "QueryString UName=";
              // Display QueryString
              lblQstring.Text += Request.QueryString["UName"];
           }
        }