Query String In ASP.NET Web Forms | State Management | ASP.NET | Web Forms

 using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;


namespace QueryStringDemo

{

    public partial class WebForm1 : System.Web.UI.Page

    {

        protected void Page_Load(object sender, EventArgs e)

        {


        }


        protected void SENDButton_Click(object sender, EventArgs e)

        {

            //Here below "id" is Query String variable

            //Response.Redirect("WebForm2.aspx?id=" + Server.UrlEncode(IDTextBox.Text) + "&name=" + Server.UrlEncode(NAMETextBox.Text) + "&age=" + Server.UrlEncode(AGETextBox.Text));

            Response.Redirect("WebForm2.aspx?id=" + IDTextBox.Text.Replace("&","%26") + "&name=" + NAMETextBox.Text.Replace("&","%26") + "&age=" + AGETextBox.Text.Replace("&","%26"));

        }

    }

}

Above File is QueryStringDemo\WebForm1.aspx.cs





using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;


namespace QueryStringDemo

{

    public partial class WebForm2 : System.Web.UI.Page

    {

        protected void Page_Load(object sender, EventArgs e)

        {

            TextBox2.Text = Request.QueryString[0];

            TextBox3.Text = Request.QueryString[1];

            TextBox4.Text = Request.QueryString[2];

        }

    }

}

Above File is QueryStringDemo\WebForm2.aspx.cs








Comments

Popular posts from this blog

Range Validator Control In ASP.NET Web forms | Form Validation | ASP.NET Web forms

Query String In ASP.NET Web Forms | State Management | ASP.NET | Web Forms

Validation Summary Control In ASP.NET Web forms | Form Validation | ASP.NET