Wednesday, November 21, 2012

Query String With Example

==>>First you need have one page that have one textbox ID="NameTxtbox" and Have one button ID=" btnSubmit" Then on the button click you need write this code:---


 
protected void btnSubmit_Click(object sender, EventArgs e)
{
Response.Redirect("MainPage.aspx?Name="+NameTxtbox.Text);
}


==>> If you Want to have multiple control value on the Mainpage.aspx then you need to write this code:--


protected void btnSubmit _Click(object sender, EventArgs e)
{
Response.Redirect("MainPage.aspx?Name="+NameTxtbox.Text+"&Fname="+FNameTxtbox.Text);
}

 ==>> Get the value of Query String on the Another page:---


protected void Page_Load(object sender, EventArgs e)
{
Lblname.Text = Request.QueryString["Name"];
LblfName.Text = Request.QueryString["Fname"];
}