Mark
Mark

Reputation: 193

Accessing and editing Master page label from child page

Basically, I need to validate log-in on a child page which I've successfully done but now I'm required to edit a label on master page to show the Username of the user that successfully log in. This is basically a visual effect problem if you see it just like that but then I'm required to access the master page label from individual child page validate the username there with the table used for log-in and find out the permission status (admin or user), depending on the result activate or deactivate certain command buttons

Codes I tried to use but they don't quite work

Master.FindControl("Label1").Visible=true;
Label lb=(Label)this.master.FindControl("Label1")
lb.visible=true
lb.text=UserName.text

Please help, I have been breaking my head for day to no avail got some good answers from here the past which I used hope to have the same luck

Upvotes: 0

Views: 777

Answers (1)

Sam Axe
Sam Axe

Reputation: 33738

If you tell your master page to bind the label's value to HttpContext.User.Identity.Name, then you dont have to monkey around with anything in the child page.

In fact, I believe there's a built-in asp.net control for displaying the authentication status of a user.. though I could be wrong.

Upvotes: 2

Related Questions