Click here to Skip to main content
15,907,000 members
Please Sign up or sign in to vote.
3.89/5 (2 votes)
See more:
I want to pass the value from one page to another page in asp.net.
Where there are two pages
page1,page2
In the page1 there is a condition, if it is correct the value from the string is take to the page2 and show in the label "correct". If it is not correct the value from the page1 string is take to the page2 and show in the label "not correct".
How to take value from one page1 to page2.
Posted
Comments
Gokul Athithan 6-Nov-13 5:55am    
string server = "";

if (server != Dns.Resolve(domain).ToString())
{
string na = "Not Available!";
Response.Redirect("domainsearch.aspx?Name=" + na);
}
else
{

string nas = "Available!";
Response.Redirect("domainsearch.aspx?NoName=" + nas);
}
How i can get the error message "Available" in the Next page
Ayush Nautiyal 24-Mar-14 1:31am    
I think you should go throught state management concepts,,,,like Query string, session etc..
See "http://www.codeproject.com/Articles/492397/State-Management-in-ASP-NET-Introduction" or "http://www.tutorialspoint.com/asp.net/asp.net_managing_state.htm" link
Pranav-BiTwiser 24-Mar-14 2:19am    
use either session or query string....

Please see my recent answer: Passing Data Between Pages[^].

—SA
 
Share this answer
 
 
Share this answer
 
v2
You may use
Query Strings
Cookies
Session variables
Server.Transfer
Post Back URL


Passing data/parameters/values from one aspx page to another aspx page[^]
Passing Values from One Page to Another Page – ASP.NET[^]
 
Share this answer
 
Please go this sites I hope you will get your requirements with proper answer


Pass Values Between ASP.NET Web Pages



Eight Different Ways to Transfer Data from One Page to Another Page
 
Share this answer
 
v2
query string is better for small and non sensitive data
 
Share this answer
 
You can use any of the following:
1. QueryString like page2.aspx?str=true, or false depending on your choice.
2. Server.Transer("page2.aspx"); and then use for eg. Page.Previouspage.FindControl("control-name");
3. Use session object. Like session["choice"]="true" or "false" .
 
Share this answer
 
v2
Query Strings
Cookies
Session variables
Server.Transfer
Post Back URL
 
Share this answer
 
PAGE 1


C#
string correct = label1.Text.ToString();
string inCorrect = label2.Text.ToString(); 
//your condition



C#
Session["transfervalue"] = //transferlabel


THEN RETRIEVE THE SESSIONS ON YOUR SECOND PAGE (put on pageload)
C#
string retrievevalue = Convert.ToString(Session["transfervalue"]);

C#
lblDisplayCorrectorIncorrect.Text = retrievevalue;
 
Share this answer
 
 
Share this answer
 
You can use Session in Server side ,and QueryString,Viewstate,Cookie Hiddenfield in ClientSide


eg:Session Page1:

if(condition)
{
Session["Condtion"]="Correct";
}
else
{
Session["Condtion"]="InCorrect";
}

Page2

label1.text=Session["Condtion"].Tostring();
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900