Click here to Skip to main content
15,903,362 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How can i access label control id in code behind .cs from .master page.I try labelid.Text but it's not working.Please help me.

What I have tried:

Here is my master page code
C#
<asp:Label runat="server" ID="welcome">User</asp:Label>

and in code behind
C#
 protected void Page_Load(object sender, EventArgs e)
    {
       welcome.text // this is not working 

       
        
}
Posted
Comments
F-ES Sitecore 26-Mar-16 8:36am    
It should work (assuming all of this is on the master page, not the content page), try deleteing the control, saving, then re-adding it as that sometimes sorts it out. You need to look at the designer file to ensure your welcome label is defined in there, and if it isn't you could always add it manually.
Hameed Khan 26-Mar-16 12:32pm    
How can i add it manually?
Anil Sharma1983 29-Mar-16 5:42am    
If you have master.aspx.designer.cs file in your project ,here you can check syntax already declare control in designer file
Ie
protected global::System.Web.UI.WebControls.DropDownList DropDownList1;

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