I a开发者_C百科m doing a project on c#.net using sql server 2005.
I have a login.aspx and homepage.aspx. I want to save value of textbox "username" from login.aspx and want it to be displayed on homepage.aspx using label control.
Also, I am using .net's inbuilt login control and dont know how to access the database/table created automatically by .net. So will you also tell me that?
Please help me.
Thanks in advance, Nikhil
If you are using the asp.net login system then you can use the <asp:LoginName />
control:
- http://www.google.co.uk/search?q=asp.net+loginname
If you want to access this information via code you can use:
string username = HttpContext.Current.User.Identity.Name;
Since you are using the built in features, you can access the user's name with context.user.identity.name
To store a value so that other pages can access it, you can use Session("username") = txtLogin.Text
Session variables can be accessed by any page while the user's session is active.
精彩评论