Passs (Send) value from one page to another using C# in ASP.Net

indradeo
 
on Oct 06, 2021 07:07 AM
661 Views

i want to pass values from Index page to Default and display in TextBox1.

Download FREE API for Word, Excel and PDF in ASP.Net: Download
arjunv
 
on Oct 07, 2021 04:39 AM

Dear Indradeo,

   kindly refer below Sample.

 HTML

Home

 <asp:TextBox runat="server" ID="txtId" />
        <asp:Button Text="Save" runat="server" ID="btnSave" OnClick="Save" />

Default

<asp:TextBox runat="server" ID="txtEmpId" />

Code

 Home

protected void Save(object sender, EventArgs e)
{
    Session["empid"] = txtId.Text;
    Response.Redirect("~/Default.aspx?empid=" + Session["empid"].ToString().Trim());
}

Default

protected void Page_Load(object sender, EventArgs e)
{
    if (!this.IsPostBack)
    {
        txtEmpId.Text = Request.QueryString["empid"];
    }
}

Screenshot