Send data from one page to another

前端 未结 5 1223
面向向阳花
面向向阳花 2020-12-01 17:28

I am trying to send form data from one page to another using C# ASP.Net. I have two pages default.aspx and default2.aspx.Here is the code I have in default.aspx:

         


        
5条回答
  •  [愿得一人]
    2020-12-01 18:00

    Session variables can be useful in this context.

    Foe example suppose your textboxes contain login credentials, then save them in sessions so that you can later use them in any other page. Like this:

    In Button_Click-

    Session["name"]=TextBox1.Text;
    Session["pwd"]= TextBox2.Text;
    

    Instead of PostBackUrl="~/Default2.aspx" you can write the following-

    //in button click
    Server.Transfer("~/Default2.aspx");
    

    In Default2.aspx page load:

    string a= Session["name"].ToString();
    string b= Session["pwd"].ToString();
    

提交回复
热议问题