Click here to Skip to main content
15,895,812 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am Working on my Project, on Which i have Created a 2 Master Page and his 10 child pages for each. 1 is For admin and other One is For Application User.

Upon Login User id and his name has to pass on each child page.

I need to know this Can I pass the user id and name to the only master page and then child pages can access these variables from master page.
Posted

Wherever you set the Session, it would be available in all pages for one particular Session.
 
Share this answer
 
Comments
Sanket Saxena 16-Apr-14 12:37pm    
correct just need to set the login name in a sesion variable and use it wherever you want in the application till that session
Unnecessary.
The Page class has a User property which contains the user's Priciple object.
see http://msdn.microsoft.com/en-us/library/system.web.ui.page.user(v=vs.110).aspx[^]

So, in any page you can do
C#
var username = Page.Identity.Name;

Using the username, you can use the Membership or Aspnet.Identity system to get any other user details.

If you are using AspNet.Identity, the User may have Claims the contain the additional information you require, eliminating the need to make a call that potentially accesses the database.
 
Share this answer
 
v2

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