OLV.aspx has the code file OLV.aspx.cs
A line in OLV.aspx.cs say that "LogInLabel does not exist in the current context."
This is a very simple, common error, that basically says I don't have anything in OLV.aspx called LogInLabel.
However, I do.
The following is copy/pasted from the code in OLV.aspx.cs:
LogInLabel.Text = ...
The following is copy/pasted from the ID property of the label in OLV.aspx:
LogInLabel
There are Panels in my code which are invisible by default, but this label isn't part of that.
My page uses a Master Page. The code appears as follows:
if the control with the ID LoginLabel is within another control (like a repeater) you can't directly access it from the codebehind. Then how can we call them. I am also getting an error same like this in my repeater for e.CommandName.
Error 1 'System.Web.UI.WebControls.RepeaterItemEventArgs' does not contain a definition for 'CommandName' and no extension method 'CommandName' accepting a first argument of type 'System.Web.UI.WebControls.RepeaterItemEventArgs' could be found (are
you missing a using directive or an assembly reference?) C:\Users\KANHA\Documents\Visual Studio 2010\WebSites\repeater\Default.aspx.cs 49 15 C:\...\repeater\
huh? You set the onClick event name in the control definition manually, then in that event cast the Sender as type LinkButton and you can grab the .CommandName from it.
You really should post in a new thread though, as this one is mark Resolved and unlikely to get assistance.
Have you read the book? - ASP.Net 3.5 CMS Development (now on Kindle)
v5.1 of iTracker (Inventory Tracker Starter Kit) is out, Download it now!
GrassProgram...
Member
360 Points
246 Posts
"does not exist in the current context"
Apr 04, 2012 07:00 PM|LINK
OLV.aspx has the code file OLV.aspx.cs
A line in OLV.aspx.cs say that "LogInLabel does not exist in the current context."
This is a very simple, common error, that basically says I don't have anything in OLV.aspx called LogInLabel.
However, I do.
The following is copy/pasted from the code in OLV.aspx.cs:
LogInLabel.Text = ...
The following is copy/pasted from the ID property of the label in OLV.aspx:
LogInLabel
It exists.
Why does it say my label doesn't exist?
Curt_C
All-Star
66017 Points
7639 Posts
Moderator
Re: "does not exist in the current context"
Apr 04, 2012 07:03 PM|LINK
if the control with the ID LoginLabel is within another control (like a repeater) you can't directly access it from the codebehind.
v5.1 of iTracker (Inventory Tracker Starter Kit) is out, Download it now!
GrassProgram...
Member
360 Points
246 Posts
Re: "does not exist in the current context"
Apr 04, 2012 07:10 PM|LINK
There are Panels in my code which are invisible by default, but this label isn't part of that.
My page uses a Master Page. The code appears as follows:
<%@ Page Title="" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeFile="OLV.aspx.cs" Inherits="Forms_OLV" %> <asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" Runat="Server"> <style type="text/css"> .style9 { height: 17px; } </style> </asp:Content> <asp:Content ID="Content2" ContentPlaceHolderID="MainContent" Runat="Server"> You are logged in as <asp:Label ID="LogInLabel" runat="server" Text="someone"></asp:Label> - <asp:Label ID="LogInLabelRole" runat="server" Text="someone"></asp:Label> <hr /> <br /> <asp:Panel ID="OLView" runat="server"> //Stuff </asp:Panel> <asp:Panel ID="OLEdit" runat="server" Visible="False"> //Stuff </asp:Panel> <br /> <br /> </asp:Content>GrassProgram...
Member
360 Points
246 Posts
Re: "does not exist in the current context"
Apr 04, 2012 07:16 PM|LINK
And now it's suddenly not complaining anymore, even though I haven't changed a thing...
jprochazka
Contributor
4896 Points
740 Posts
Re: "does not exist in the current context"
Apr 04, 2012 07:18 PM|LINK
- NM misread the code... -
Rakesh.460
Member
5 Points
13 Posts
Re: "does not exist in the current context"
Apr 05, 2012 05:45 PM|LINK
if the control with the ID LoginLabel is within another control (like a repeater) you can't directly access it from the codebehind. Then how can we call them. I am also getting an error same like this in my repeater for e.CommandName.
Error 1 'System.Web.UI.WebControls.RepeaterItemEventArgs' does not contain a definition for 'CommandName' and no extension method 'CommandName' accepting a first argument of type 'System.Web.UI.WebControls.RepeaterItemEventArgs' could be found (are you missing a using directive or an assembly reference?) C:\Users\KANHA\Documents\Visual Studio 2010\WebSites\repeater\Default.aspx.cs 49 15 C:\...\repeater\
How should i call my Linkbutton event
Curt_C
All-Star
66017 Points
7639 Posts
Moderator
Re: "does not exist in the current context"
Apr 05, 2012 06:45 PM|LINK
huh? You set the onClick event name in the control definition manually, then in that event cast the Sender as type LinkButton and you can grab the .CommandName from it.
You really should post in a new thread though, as this one is mark Resolved and unlikely to get assistance.
v5.1 of iTracker (Inventory Tracker Starter Kit) is out, Download it now!
Rakesh.460
Member
5 Points
13 Posts
Re: "does not exist in the current context"
Apr 06, 2012 07:03 PM|LINK
I did not get you, can you give a example.
Thanx for answering