Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > The name 'blMessages' does not exist in the current context

Reply
Thread Tools

The name 'blMessages' does not exist in the current context

 
 
J055
Guest
Posts: n/a
 
      01-09-2007
Hi

I'm using VS2005. I get the above error when trying to build the solution.
Intellisense is OK.

// Code behind
protected void odsPublication_Inserted(object sender,
ObjectDataSourceStatusEventArgs e)
{
if (e.Exception == null)
{
blMessages.Visible = false;
}
}

//This is the webcontrol and ObjectDataSource

<asp:BulletedList ID="blMessages" runat="server" ForeColor="Red"
Visible="False">
</asp:BulletedList>
<asp:ObjectDataSource ID="odsPublication" runat="server"
InsertMethod="AddPublication"
OnInserted="odsPublication_Inserted">
<SelectParameters>
....

</SelectParameters>
<InsertParameters>
....
</InsertParameters>
</asp:ObjectDataSource>

Can you tell me what it really means and how to fix it?

Thanks
Andrew


 
Reply With Quote
 
 
 
 
Mike
Guest
Posts: n/a
 
      01-09-2007

"J055" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> Hi
>
> I'm using VS2005. I get the above error when trying to build the solution.
> Intellisense is OK.
>
> // Code behind
> protected void odsPublication_Inserted(object sender,
> ObjectDataSourceStatusEventArgs e)
> {
> if (e.Exception == null)
> {
> blMessages.Visible = false;
> }
> }
>
> //This is the webcontrol and ObjectDataSource
>
> <asp:BulletedList ID="blMessages" runat="server" ForeColor="Red"
> Visible="False">
> </asp:BulletedList>
> <asp:ObjectDataSource ID="odsPublication" runat="server"
> InsertMethod="AddPublication"
> OnInserted="odsPublication_Inserted">
> <SelectParameters>
> ...
>
> </SelectParameters>
> <InsertParameters>
> ...
> </InsertParameters>
> </asp:ObjectDataSource>
>
> Can you tell me what it really means and how to fix it?
>


This usually means that the control you are trying to reference is inside a
template field of a data control (gridview? repeater?) or otherwise not
directly accessible from wherever you have your code-behind. You need to
use the FindControl method to get to it:

BulletedList blist = (BulletedList)<DataControl>.FindControl("blMessage s");

<DataControl> is the name of the housing control - GridView1 or whatever you
have called it.

HTH

Mike


 
Reply With Quote
 
 
 
 
Steven Cheng[MSFT]
Guest
Posts: n/a
 
      01-10-2007
Hi Andrew,

As for the ASP.NET web page, can you directly run it(view in the browser)
without compiling the entire website? I've found some other threads
discussing on this issue. It seems such behavior is likely due to the
status of that page in the project be corrupted. From those threads, you
can try the following things to see whether it works:

1. exclude the problem page from the project and close the VS IDE.
Reopen the solution/project and include the page again.

2. create a new page and copy all the markup and controls from the problem
page to the new page. remove the old problem page and compile the site
again.

Here is a thread on MSDN forum discussing on this:

http://forums.microsoft.com/MSDN/Sho...00532&SiteID=1

Hope this helps.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


This posting is provided "AS IS" with no warranties, and confers no rights.

 
Reply With Quote
 
Mike
Guest
Posts: n/a
 
      01-10-2007

"Mike" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>
> "J055" <(E-Mail Removed)> wrote in message
> news:%(E-Mail Removed)...
>> Hi
>>
>> I'm using VS2005. I get the above error when trying to build the
>> solution. Intellisense is OK.
>>
>> // Code behind
>> protected void odsPublication_Inserted(object sender,
>> ObjectDataSourceStatusEventArgs e)
>> {
>> if (e.Exception == null)
>> {
>> blMessages.Visible = false;
>> }
>> }
>>
>> //This is the webcontrol and ObjectDataSource
>>
>> <asp:BulletedList ID="blMessages" runat="server" ForeColor="Red"
>> Visible="False">
>> </asp:BulletedList>
>> <asp:ObjectDataSource ID="odsPublication" runat="server"
>> InsertMethod="AddPublication"
>> OnInserted="odsPublication_Inserted">
>> <SelectParameters>
>> ...
>>
>> </SelectParameters>
>> <InsertParameters>
>> ...
>> </InsertParameters>
>> </asp:ObjectDataSource>
>>
>> Can you tell me what it really means and how to fix it?
>>

>
> This usually means that the control you are trying to reference is inside
> a template field of a data control (gridview? repeater?) or otherwise not
> directly accessible from wherever you have your code-behind. You need to
> use the FindControl method to get to it:
>
> BulletedList blist =
> (BulletedList)<DataControl>.FindControl("blMessage s");
>
> <DataControl> is the name of the housing control - GridView1 or whatever
> you have called it.


Oops. Missed the bit about Intellisense in your OP.


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
"the name <some control> does not exist in the current context" avecreep ASP .Net 0 08-05-2008 07:28 AM
The name 'Container' does not exist in the current context Peter Morris ASP .Net 2 03-17-2008 05:57 PM
The name <name> does not exist in the current context Montand ASP .Net 1 02-20-2008 08:09 AM
The name 'UserName' does not exist in the current context"? =?Utf-8?B?TWljaGFlbA==?= ASP .Net 3 10-26-2006 10:57 PM
The name 'Container' does not exist in the current context Arjen ASP .Net 1 08-21-2006 07:14 PM



Advertisments