Arianule
Arianule

Reputation: 9043

Not picking up id of control in code behind

I have a basic webform(Default.aspx) that I created using and master page and bizarrely I am not able to access the id of a control in the code behind.

<ul id="topicsList" runat="server">
                                <asp:Label ID="labUserName" runat="server"/>
                            </ul>

IDomainObjectRepository rep;
protected void Page_Load(object sender, EventArgs e)
{
    rep = new DomainObjectRepository();
    rep.GetDomainObjectsByType("Visuals Product Label");
    /*labUserName not picked up by intellisense*/

}

any pointers as to why this could be the case

Upvotes: 0

Views: 432

Answers (1)

Chris Dixon
Chris Dixon

Reputation: 9167

The problem is likely due to your Code-front not being referenced by code behind, or vice versa. Make sure you have the following (double check the CodeBehind and code-behind class marry up):

public class _Default : Page
{
   // Your load event
}

<%@ Page Title="" Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="_Default" %>

Upvotes: 1

Related Questions