Click here to Skip to main content
15,867,895 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have a project in VS 2013 with master page. In the Root.master I have the "Log In" which redirects me to the login page.
ASP.NET
<a href="Logare.aspx"><asp:Label ID="Label8" runat="server" Text="Log In"></asp:Label></a>

When I login I'm redirected to a certain page, let's say it Default.aspx.
In Default.aspx.cs I have:
C#
Label mpLabel = (Label)Master.FindControl("Label8");
                if (mpLabel != null)
                {
                    Label1.Text = "Master page label = " + mpLabel.Text;
                     mpLabel.Text = Session["username"].ToString();
                }

The MasterPageFile for Default.aspx is:
HTML
MasterPageFile="~/Main.master"

How could I do so when I'm logged in the text from Root.master to change from "Log In" to "Welcome, username"? I tried to get the Label8 id from Root.master but it's not known in Default.aspx.cs.

What I have tried:

If necessary I'll provide the needed code.
Posted
Updated 6-Apr-16 23:36pm
v2
Comments
F-ES Sitecore 7-Apr-16 5:30am    
What is the relation between root.master and main.master?

In general if the label is on a master page then the code to make it say what you want should be in the page_load event in the code-behind for the master page it is on.
DrgIonuţ 7-Apr-16 5:42am    
This is what I wanna find out. As I see the structure of the project, it seems like is no relation. I want to change the label's text which is Root.master. But the page (Default.aspx) is in Content -> MainContent which is part of Main.master. I hope I'm not mistaken. I'm sorry but I just started to work with master pages so that's why I'm confused and don't know how to do it. Thanks for your patience!
F-ES Sitecore 7-Apr-16 5:46am    
If root.master isn't a master page for the current content page (more precisely, if it isn't anywhere in the page hierarchy as you can have nested masters) then you can't change anything on it as it isn't used.
DrgIonuţ 7-Apr-16 5:51am    
Isn't there any way to add a sort of reference so I have access to that label?
F-ES Sitecore 7-Apr-16 5:52am    
If it's not shown on the page what's the point in amending it? No-one is going to see it.

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