patd1
asked on
Cant find a label control in the code behind
I have default.aspx page and default.aspx.cs page. I just added a label (UserName) to my default.aspx page and tried to set the text of that label in the page_load method in the code behind. I get a compilation error: UserName does not exist in the current context. This seems to be the simplest change but is not working. Please check my code and advise change.
Thank You.
Thank You.
<%@ Page Language="C#" MasterPageFile="MyMaster.master" AutoEventWireup="true"
CodeFile="Default.aspx.cs" Inherits="_Default" EnableViewState="true" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit"%>
<div id="simple">
<table>
<tr>
<td>
<asp:Panel ID="panelSimple" CssClass="float_left" runat="server" GroupingText="User"
EnableViewState="false">
<table>
<tr>
<td>
User Name: <asp:Label ID = "UserName" runat = "server"></asp:Label>
</td>
</tr>
...
</table>
</Panle>
..
...
</td>
</tr>
</table>
</div>
public partial class _Default : MyUserInformation
{
protected void Page_Load(object sender, EventArgs e)
{
string UserRole = this.MuUserRole;
UserName.Text = this.MyUserRole;
//this.UserName.Text = this.MyUserRole;
...
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank for your reply. I just noticed that there were two defaults in solution. I deleted one and it works now.
Thank You.
Thank You.
Are you going to close this question?
/// <summary>
/// UserName control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebC