如何在Asp.Net的主页面上提供注册详细信息? [英] How to make the registration details available to main page in Asp.Net?

查看:79
本文介绍了如何在Asp.Net的主页面上提供注册详细信息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建一个具有注册页面,登录页面和主页面的Web应用程序。用户首次在注册页面输入详细信息(用户名,密码,邮件ID,电话号码),并在连续访问时在登录页面输入详细信息(仅限用户名和密码)

我需要以下内容已经实现



- 将用户在注册时提供的邮件ID提供给主页



我的这个代码



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

//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"];
}





我无法显示邮件ID,因为注册页面仅用于一次在注册过程中,如果普通用户登录,用户将填写登录页面中的详细信息。那么如果普通用户(每次都没有使用注册页面的人),如何在主页面上提供注册详细信息。请help.I我刚接触.Net.Thanks提前



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

推荐答案




登录时存储用户会话变量中的邮件ID



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

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







然后在另一页中检索邮件ID,如






then in the other page retrieve mail id like

lblWelcomeUsername.Text = Session["username"].ToString();


首先,您为电子邮件ID创建会话,该会话是唯一的,如果电子邮件ID和密码有效则在提交按钮获取数据匹配数据,然后是Response.Redirect(〜/ Mainpage.aspx);



例如



这是用于登录页面提交按钮点击事件



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

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







这是主页显示电子邮件ID






This for MainPage to Show Email Id

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





试试这个应该可行。



try this it should work.


这些用户的详细信息来自注册页面应保存到数据库中。然后,当注册用户重新访问该站点时,他必须在登录页面进行身份验证。经过身份验证后,您可以获取他的详细信息,例如邮件ID,来自数据库并存储在会话变量中。

ASP.Net中的简单用户注册表单示例 [ ^ ]
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[^]


这篇关于如何在Asp.Net的主页面上提供注册详细信息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆