Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Apr 06, 2012 07:03 PM by Rakesh.460
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:
Why does it say my label doesn't exist?
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.
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">
<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>
<asp:Panel ID="OLView" runat="server">
<asp:Panel ID="OLEdit" runat="server" Visible="False">
Apr 04, 2012 07:16 PM|LINK
And now it's suddenly not complaining anymore, even though I haven't changed a thing...
Apr 04, 2012 07:18 PM|LINK
- NM misread the code... -
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
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.
Apr 06, 2012 07:03 PM|LINK
I did not get you, can you give a example.
Thanx for answering