You have several options, consider
- Session Status
- Query string
Session Status
If you intend to send data between pages, you might consider using Session State .
An ASP.NET session state allows you to store and retrieve values ββfor a user as the user navigates through ASP.NET pages in a web application. HTTP is a stateless protocol. This means that the web server processes each HTTP request per page as a standalone request. The server does not retain knowledge of the values ββof the variables that were used during previous queries. An ASP.NET session state identifies requests from the same browser during a limited time window as a session, and provides a way to store variable values ββfor the duration of that session. By default, ASP.NET Session State is enabled for all ASP.NET applications.
Best of all, it's easy!
Put the data (e.g. in default1.aspx)
Session["FirstName"] = FirstNameTextBox.Text; Session["LastName"] = LastNameTextBox.Text;
Get it (e.g. on default2.aspx)
string firstname = Session["FirstName"] // value of FirstNameTextBox.Text; string lastname = Session["LastName"] // value of LastNameTextBox.Text;
Query string
If you send small amounts of data (e.g. id = 4), it may be more practical to use query string variables.
You should study the use of query string variables like
http:
Then you can get the data as
string param1 = Request.QueryString["param1"];
You can use something like How to check Request.QueryString [] variables? to get the data.
If you are not familiar with query string variables, check out their Wikipedia article.
source share