August 23, 2012

How to pass value to query string in asp dot net

Query string is used to Pass the values or information form one page to another page.

 //First page of aspx  
 Partial Class Test1  
   Inherits System.Web.UI.Page  
   Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click  
    'bind the textbox values to querystring  
     Response.Redirect("Test2.aspx?ValuefromTxtbox1=" & TxtBoxControl1.Text)  
   End Sub  
 End Class  
 //Second page of aspx  
 Partial Class Test2  
   Inherits System.Web.UI.Page  
   Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load  
     'Get the values from Query string  
     TxtBoxControl1.Text = Request.QueryString("ValuefromTxtbox1")  
   End Sub  
 End Class