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

Discussion in 'ASP .Net' started by J055, Jan 9, 2007.

  1. J055

    J055 Guest

    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
     
    J055, Jan 9, 2007
    #1
    1. Advertising

  2. J055

    Mike Guest

    "J055" <> wrote in message
    news:%...
    > 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("blMessages");

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

    HTH

    Mike
     
    Mike, Jan 9, 2007
    #2
    1. Advertising

  3. 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/ShowPost.aspx?PostID=200532&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.
     
    Steven Cheng[MSFT], Jan 10, 2007
    #3
  4. J055

    Mike Guest

    "Mike" <> wrote in message
    news:...
    >
    > "J055" <> wrote in message
    > news:%...
    >> 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("blMessages");
    >
    > <DataControl> is the name of the housing control - GridView1 or whatever
    > you have called it.


    Oops. Missed the bit about Intellisense in your OP.
     
    Mike, Jan 10, 2007
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Arjen
    Replies:
    1
    Views:
    9,754
    =?Utf-8?B?RGF2aWQgSmVzc2Vl?=
    Aug 21, 2006
  2. =?Utf-8?B?TWljaGFlbA==?=

    The name 'UserName' does not exist in the current context"?

    =?Utf-8?B?TWljaGFlbA==?=, Oct 26, 2006, in forum: ASP .Net
    Replies:
    3
    Views:
    830
    Mark Fitzpatrick
    Oct 26, 2006
  3. Montand
    Replies:
    1
    Views:
    552
    Alexey Smirnov
    Feb 20, 2008
  4. Peter Morris
    Replies:
    2
    Views:
    6,639
    Peter Morris
    Mar 17, 2008
  5. avecreep
    Replies:
    0
    Views:
    576
    avecreep
    Aug 5, 2008
Loading...

Share This Page