Click here to Skip to main content
15,888,177 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am building a web application which has a registration page ,login page and main page. User enters details in registration page for the first time(username,password,mail id,phone number) and on successive visits enters details in login page(Username and password only)
I need the following to be achieved

- Make the mail id that the user gave on registration available to the main page

My code for this

C#
//Code in registration page for fetching mail id
protected void Page_Load(object sender, EventArgs e)
{
   Session["txt1"] = TextBoxname.Text;
}

//code for displaying the mail id fetched from registration page
protected void Page_Load(object sender, EventArgs e)
{
   WelcomeUsername.Text = (string)Session["txt1"];
}


I am not able to display the mail id because the registration page is used only for a single time that is during registration but if a regular user logs in the user will fill details in login page.So how can I make the registration details available to main page in case of regular user(one who is not using registration page each and every time).Please help.I am new to .Net.Thanks in advance
Posted
Updated 2-Nov-14 22:58pm
v2

Hi
at the time of login store the user mail id in a session variable

C#
private void btnlogin_Click(object sender, EventArgs e)
        {
               // code for login check
              Session["username"] = TextBoxname.Text;
}



then in the other page retrieve mail id like

lblWelcomeUsername.Text = Session["username"].ToString();
 
Share this answer
 
Firstly you create session for email id which is unique and on submit button fetch data match data if email id and password is valid then Response.Redirect("~/Mainpage.aspx");

For Example

This is for login page submit button click event

C#
protected void submit_Click(object sender, EventArgs e)
{
    Session["emailId"] = txtemailId.Text;
    Response.Redirect("~/MainPage.aspx");
}



This for MainPage to Show Email Id

C#
protected void Page_Load(object sender, EventArgs e)
   {
       lblEmailId.Text = Session["emailId"].ToString();
   }


try this it should work.
 
Share this answer
 
Those user's details from the registration page should be saved to a database. Then when a registered user re-visits the site, he have to be authenticated at the login page. Upon authenticated, you can get his details, e.g. mail id, from the database and stored them in session variables.
Simple User Registration Form Example in ASP.Net[^]
 
Share this answer
 
Comments
Member 11176603 3-Nov-14 6:56am    
Could you please tell me how to get the details from the database when the user is authenticated at the login page?I created a table which holds all the details but I know how to check if the user is a valid user or not but I dont know how to get values upon authentication
Peter Leow 3-Nov-14 7:19am    
Run a SQL select query to retrieve the data say "mail id" from the table using username as the criterion in the where clause.

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