Hi Friends
I am doing Asp.Net web project.
In one web form i am getting user information. After that i am redirecting into 2nd form. While redirecting i need to send the first form user information to the 2nd form. How to send it ? or from 2nd form i want to get the first form details. how to get it ?
I have searched in MSDN library and got some ideas. Which I want to share here.
Use a query string, which appends information onto the URL and passes it to the next page. This has the disadvantage of making the information visible.
Use Session state to store information that is then accessible globally to all pages in the user's current session. However, this takes server memory and the information is stored until the session expires.
Instead of using thOse methods we can create a read only property of the particular value. Then we can access the property from target webform.
Write the following code into the source page,
//I am using C##
public string u_name
{
get
{
return Txtusername.Text;
}
}
You must create a global instance variable for the source webform (webform1)
//This code must place on the webform1
public WebForm1 sourcepage;
In a button click handler write the following code to redirect into second web form
Server.Transform("webform2.aspx")
Now you can get the source page through Context.Handler object.
I said request.Form, where the information passed between forms are hidden to user, but not to pages. Or if you want use Session variables, itīs the same thing in some ways, the Session variables are accessed via ASP code but not accessed by the user.
Request.Querystring appends variables to the URL, and if you want to send confidential data, do NOT use this way. Or if you use this, encrypt data.