'__o' is not declared - what does it mean?

Last post 11-17-2009 7:20 PM by msandfox. 16 replies.

Sort Posts:

  • '__o' is not declared - what does it mean?

    09-29-2005, 11:25 AM
    • Participant
      760 point Participant
    • gilkesy
    • Member since 07-01-2004, 4:36 AM
    • Posts 152
    I have a web page that has 21 errors all pointing to the same place and each error is the same as this first one::

    Error    1    Name '__o' is not declared.    C:\Data\Artwork\web sites\MRL Insurance Direct Web Site\web-content\affiliate\stats1.aspx    97    1    C:\...\web-content\

    What does it mean?
  • Re: '__o' is not declared - what does it mean?

    09-29-2005, 2:59 PM
    • Star
      8,834 point Star
    • MorningZ
    • Member since 07-22-2002, 2:39 PM
    • Fort Lauderdale, FL
    • Posts 1,815
    So what is the code on line 97 in stats1.aspx
    "If you make it idiot proof, they'll build a better idiot"
  • Re: '__o' is not declared - what does it mean?

    09-29-2005, 3:07 PM
    • Participant
      760 point Participant
    • gilkesy
    • Member since 07-01-2004, 4:36 AM
    • Posts 152
    This:

    </script>

  • Re: '__o' is not declared - what does it mean?

    09-29-2005, 3:14 PM
    • Participant
      760 point Participant
    • gilkesy
    • Member since 07-01-2004, 4:36 AM
    • Posts 152
    Here's a screen-grab showing the problem:

    http://www.gilkes.me.uk/aspnet/01.html

    (its now line 88 as I've made some changes to the script)
  • Re: '__o' is not declared - what does it mean?

    10-03-2005, 2:24 PM
    ASP.NET runtime generates a few internal class members that are necessary to support inline expressions like <%# %>. There is something wrong with the code that is not visible to you. It would be useful if you could post the entire page markup.
    Thanks

    ------------------------------------------------------------

    This posting is provided "AS IS" with no warranties, and confers no rights.
  • Re: '__o' is not declared - what does it mean?

    10-05-2005, 11:03 AM
    • Participant
      760 point Participant
    • gilkesy
    • Member since 07-01-2004, 4:36 AM
    • Posts 152
    Mikhail

    Thanks for your reply. Unfortunately (or should that be fortunately) the errors no longer show in the Error list.

    I had made some changes to the page (which involved removing some inline code)  and the errors disappeared.

    At least I know what causes the errors now. Perhaps they should be better documented than just "__o"

    Regards
    Stephen
  • Re: '__o' is not declared - what does it mean?

    11-09-2005, 8:57 AM
    • Member
      5 point Member
    • GnosticTom
    • Member since 11-09-2005, 1:52 PM
    • Posts 1
    I just ran across the same issue.  What I was trying to do was to do inline conditional display of HTML:

          <%
              If valueCountyName <> "" Then
          %>
         <DIV align=left><STRONG>&nbsp;&nbsp;Multi-Jurisdiction:&nbsp;<FONT
          color=maroon><%=valueCountyName%></FONT></STRONG></DIV>
          <%
              End If
          %>
     
    With this in place, ever <%=whatever%> below this resulted in the error.  But the page would render correctly in the browser and there was no problem at runtime.  When I took out the "If" from around the DIV, the errors went away.

    Why can't I do this in ASP.NET?  I know it is old school ASP Classic style, but it still should work.
    (trying this in Microsoft Visual Studio 2005 Version 8.0.50215.44)
  • Re: '__o' is not declared - what does it mean?

    02-06-2006, 6:23 AM
    • Participant
      1,077 point Participant
    • bgs264
    • Member since 02-06-2006, 11:19 AM
    • Salford, England, UK
    • Posts 197
    Sorry to re-open an old thread, but I am having this problem using Visual Studio 2005 8.0.50727.42:

    Here is my markup:

    <div id="ContentBox4" class="ContentBox">
                The most requested items:-
                <ul>
                    <%  For Each drow As Data.DataRow In ServiceInteraction.Service.ItemOffers_Get_Top5Requests.Tables(0).Rows
                            ' Work out how long ago it was posted:
                            Dim timePosted As TimeSpan = Now.Subtract(CDate(drow.Item("dateListed")))
                    %>           
                    <li>
                        <a href="ViewItem/ViewItem.aspx?ItemID=<%=drow.item("itemID")%>">
                        <%=drow.Item("itemName")%></a> [in <%=drow.Item("categoryName")%>]
                        <br />
                        <em><%=drow.Item("requests")%>
                        <% If CInt(drow.Item("requests")) = 1 Then%>
                        request.
                        <% Else%>
                        requests.
                        <% end if %>
                        </em>
                        <br />               
                        <%
                        If timePosted.Days > 0 Then
                                Response.Write("...... " & timePosted.Days & " days and " & timePosted.Hours & " hours ago")
                            ElseIf timePosted.Hours = 0 AndAlso timePosted.Days = 0 Then
                                Response.Write("...... " & timePosted.Minutes & " minutes ago")
                        Else
                                Response.Write("...... " & timePosted.Hours & " hours ago")
                        End If
                        %>
                    </li>
                    <%Next%>
                </ul>
            </div>

    I am getting blue-squiggly line and the error "Name __o is not declared" on the following lines:
    • The first <li>
    •  <%=drow.Item("itemName")%>
    • <%=drow.Item("categoryName")%>
    • <%=drow.Item("requests")%>
    Thanks in advance for any advice anybody can offer.

    Similar to the above posts, this shows as a build error in the IDE - yet the project builds fine ("Build Succeeded" and it looks exactly right in browsers.

    Best wishes,

    Ben.
  • Re: '__o' is not declared - what does it mean?

    02-07-2006, 12:12 AM

    If I only use the pasted markup, I see a single error:

    Error 1 Name 'ServiceInteraction' is not declared. 

    I did some general editing for a few minutes, but was unable to repro the error. I guess there might be something in the site structure.

    Thanks

    ------------------------------------------------------------

    This posting is provided "AS IS" with no warranties, and confers no rights.
  • Re: '__o' is not declared - what does it mean?

    02-10-2006, 2:27 PM
    • Participant
      1,077 point Participant
    • bgs264
    • Member since 02-06-2006, 11:19 AM
    • Salford, England, UK
    • Posts 197
    Hi.

    Thank you for your reply.

    ServiceInteraction is a class within the same namespace. As you might expect; it contains methods to interact with a web service.

    I have put a screenshot of Visual Studio in "Markup View" mode at http://uni.bgs.me.uk/onotdefined.jpg - the page this markup generates is at http://uni.bgs.me.uk/FreeBay/default.aspx in case you want to see that, also.

    What did you mean by "might be something in the site structure"? Something like what?

    Again, thanks for looking at this.

    Ben.

  • Re: '__o' is not declared - what does it mean?

    04-20-2006, 5:37 PM
    Answer
    We have finally obtained reliable repro and identified the underlying issue. A trivial repro looks like this:

         <% if (true) { %>
        <%=1%>
        <% } %>
        <%=2%>
     
    In order to provide intellisense in <%= %> blocks at design time, ASP.NET generates assignment to a temporary __o variable and language (VB or C#) then provide the intellisense for the variable. That is done when page compiler sees the first <%= ... %> block.  But here, the block is inside the if, so after the if closes, the variable goes out of scope.  We end up generating something like this:

           if (true) { 
                object @__o;
                @__o = 1;
           }
           @__o = 2;


    The workaround is to add a dummy expression early in the page.  E.g. <%="" %>.  This will not render anything, and it will make sure that __o is declared top level in the Render method, before any potential ‘if’ (or other scoping) statement.

    Thanks

    ------------------------------------------------------------

    This posting is provided "AS IS" with no warranties, and confers no rights.
  • Re: '__o' is not declared - what does it mean?

    04-21-2006, 5:18 AM
    • Participant
      1,077 point Participant
    • bgs264
    • Member since 02-06-2006, 11:19 AM
    • Salford, England, UK
    • Posts 197
    Hi Mikhail,

    Thank you for addressing this issue and finding a workaround. I will try it in a few hours.

    All the best,

    Ben
  • Re: '__o' is not declared - what does it mean?

    04-24-2006, 12:07 AM
    • Member
      45 point Member
    • deeman
    • Member since 04-24-2006, 4:03 AM
    • Posts 9

    <% response.write(var) %> instead of <% =var %> removes the error without declaring __o as suggested before...

    :Drewman

  • Re: '__o' is not declared - what does it mean?

    10-29-2009, 5:04 AM
    • Member
      10 point Member
    • tux
    • Member since 06-05-2009, 1:41 PM
    • Posts 27

    Try a bit unconventional thinking.

    If your intellisense variable is out of scope, then you can simply create the variable in your class/page/module and the warning/error goes away.

    Simply add:

    Public __o As Object ' VB.net

    public object __o ; // C#


  • Re: '__o' is not declared - what does it mean?

    11-05-2009, 2:52 PM
    • Member
      291 point Member
    • Laplain
    • Member since 08-11-2005, 9:51 PM
    • Oregon
    • Posts 68

    Public __o As Object does not work in my case as I already have it declared in my .vb file. 

    Adding <%= __o%> outside the IF block works, but that causes the variable to display.   Am I missing something? Frown 

    Jasee
Page 1 of 2 (17 items) 1 2 Next >