Click here to Skip to main content
16,004,901 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have a master page in witch login or logout session after user login username show in master page.

my problem is i have a content page with comment box i want comment save with username. witch is user login.

how to get username from master page in content page

What I have tried:

how to get username from master page in content page?
Posted
Updated 9-Jan-17 17:47pm
Comments
jgakenhe 5-Jan-17 15:39pm    
Not providing code makes it difficult. If I had label named lblUsername in my MasterPage, the I would add the code below in my .aspx code behind to access it.

Label lb = Master.FindControl("lblUsername") as Label;

Label lblMasterStatus = (Label)Master.FindControl("lblStatus");
 
Share this answer
 
As per your question you want to save comment with the username.

Solution.

1. After login use a session key to store the username like Session["UserName"] = "LoginUsername"; After storing username in session you can get the value of that session throughout the page. As you are storing the session username in master page for displaying.

2. If you want to get the master page control data data in child page then u can get the data in this way.

ControlName ControlID = (ControlName)Master.FindControl("ControlID");
 
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