Solved

'__o' is not declared. It may be inaccessible due to its protection level.

Posted on 2010-11-20
5
2,929 Views
Last Modified: 2013-11-07
Hi

I have 10-15 errors of this kind

'__o' is not declared. It may be inaccessible due to its protection level.

at my <%: start tags

Im new to this, so why do i get this error and how do i fix it.
I have looked at the numbers 0 that its not the letter oO, and the other way bag
And its ok...

    <tr>
            <td colspan="3" align="right">Netto:</td>
            <td align="right">
            <%: (Model.Cart.ComputeTotalValue() * 0.8D).ToString("c")%>
            </td>
    </tr>
    <tr>
            <td colspan="3" align="right">Moms 25%:</td>
            <td align="right">
            <%: (Model.Cart.ComputeTotalValue() * 0.2D).ToString("c")%>
            </td>
    </tr> 

Open in new window


This is my Index.aspx site that shows the items and price
<%@ Page Language="vb" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<Store.WebUI.Models.CartIndexViewModel>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
NetButik : Din Kurv
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<h2>Din Kurv</h2>
<table width="90%" align="center">
    <thead><tr>
        <th align="center">Antal</th>
        <th align="left">Vare</th>
        <th align="right">Pris</th>
        <th align="right">Total</th>
    </tr></thead>
    <tbody>
    <% For Each line In Model.Cart.Lines%>
        <tr>
            <td align="center"><%: line.Quantity %></td>
            <td align="left"><%: line.Product.Name %></td>
            <td align="right"><%: line.Product.Price.ToString("c") %></td>
            <td align="right">
            <%: (line.Quantity*line.Product.Price).ToString("c") %>
            </td>
            <td>
            <% Using Html.BeginForm("RemoveFromCart", "Cart")%>
            <%: Html.Hidden("ProductId", line.Product.ProductID) %>
            <%: Html.HiddenFor(Function(x) x.ReturnUrl)%>
            <input type="submit" value="Slet Vare" />
            <% End Using%>
            </td>
        </tr>
    <% Next%>
    </tbody>
    <tfoot>
    <tr>
            <td colspan="3" align="right">Netto:</td>
            <td align="right">
            <%: (Model.Cart.ComputeTotalValue() * 0.8D).ToString("c")%>
            </td>
    </tr>
    <tr>
            <td colspan="3" align="right">Moms 25%:</td>
            <td align="right">
            <%: (Model.Cart.ComputeTotalValue() * 0.2D).ToString("c")%>
            </td>
    </tr>
    <tr>
            <td colspan="3" align="right">Total:</td>
            <td align="right">
            <%: Model.Cart.ComputeTotalValue().ToString("c") %>
            </td>
    </tr></tfoot>
</table>
<p align="center" class="actionButtons">
<a href="<%: Model.ReturnUrl %>">Gå tilbage og handle.</a>
<%: Html.ActionLink("Check out now", "CheckOut") %>
</p>
</asp:Content>

Open in new window


the ComputeTotalValue function is from here
Imports System
Imports System.Collections.Generic
Imports System.Linq
Imports System.Text

Namespace Store.WebUI.Entities
    Public Class Cart
        Private m_lines As New List(Of CartLine)()
        Public ReadOnly Property Lines() As IList(Of CartLine)
            Get
                Return m_lines.AsReadOnly()
            End Get
        End Property

        Public Sub AddItem(ByVal product As Product, ByVal quantity As Integer)
            Dim line = m_lines.FirstOrDefault(Function(x) x.Product.ProductID = product.ProductID)
            If line Is Nothing Then
                m_lines.Add(New CartLine() With { _
                 .Product = product, _
                 .Quantity = quantity _
                })
            Else
                line.Quantity += quantity
            End If
        End Sub

        Public Function ComputeTotalValue() As Decimal
            Return m_lines.Sum(Function(l) l.Product.Price * l.Quantity)
        End Function

        Public Sub Clear()
            m_lines.Clear()
        End Sub

        Public Sub RemoveLine(ByVal product As Product)
            m_lines.RemoveAll(Function(l) l.Product.ProductID = product.ProductID)
        End Sub

        Public Property i() As Integer
            Get
                Return m_i
            End Get
            Set(ByVal value As Integer)
                m_i = value
            End Set
        End Property
        Private m_i As Integer
    End Class

    Public Class CartLine
        Public Property Product() As Product
            Get
                Return m_Product
            End Get
            Set(ByVal value As Product)
                m_Product = value
            End Set
        End Property
        Private m_Product As Product
        Public Property Quantity() As Integer
            Get
                Return m_Quantity
            End Get
            Set(ByVal value As Integer)
                m_Quantity = value
            End Set
        End Property
        Private m_Quantity As Integer
    End Class
End Namespace

Open in new window


0
Comment
Question by:tjgrindsted
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
5 Comments
 
LVL 36

Expert Comment

by:Miguel Oz
ID: 34180859
Is '__o'  defined on the master page?
If so, it is private to the page?
You need to make a public property: (I assume __o is a button, change it as needed)
        public Button MyO
        { get { return __o; } }
0
 

Author Comment

by:tjgrindsted
ID: 34180961
Hi Mas oz2003

No its not a button, i dont know where thats comming from..

My Master site is like this
<%@ Master Language="VB" AutoEventWireup="false" CodeBehind="Site.master.vb" Inherits="System.Web.Mvc.ViewMasterPage" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
    <title><asp:ContentPlaceHolder ID="TitleContent" runat="server" /></title>
    <link rel="Stylesheet" href="../../Content/Site.css" />
    <style type="text/css">
        DIV#categories A {
        font: bold 12px verdana,arial,helvetica,sans-serif; display: block;
        text-decoration: none; padding: 3px; color: Black;
        border-bottom: 1px solid silver;
        }
        DIV#categories A.selected { background-color: #666; color: White; }
        DIV#categories A:hover { background-color: #CCC; }
        DIV#categories A.selected:hover { background-color: #666; }
    </style>
</head>
    <body>
        <div id="header">
        <%  If Not (TypeOf ViewContext.Controller Is Store.WebUI.Store.WebUI.Controllers.CartController) Then
                Html.RenderAction("Summary", "Cart")
            End If
 %>
            <div class="title">NetButik</div>
        </div>
        <div id="categories">
            <% Html.RenderAction("Menu", "Nav") %>
        </div>
        <div id="content">
            <asp:ContentPlaceHolder ID="MainContent" runat="server" />
        </div>
    </body>
</html>

Open in new window

0
 

Assisted Solution

by:tjgrindsted
tjgrindsted earned 0 total points
ID: 34181004
I get the errors after i have converted the files from C# to VB.Net
The C# code is like this.
dont know if its a converting error...

index.aspx
<table width="90%" align="center">
    <thead><tr>
        <th align="center">Antal</th>
        <th align="left">Vare</th>
        <th align="right">Pris</th>
        <th align="right">Total</th>
    </tr></thead>
    <tbody>
    <% foreach(var line in Model.Cart.Lines) { %>
        <tr>
            <td align="center"><%: line.Quantity %></td>
            <td align="left"><%: line.Product.Name %></td>
            <td align="right"><%: line.Product.Price.ToString("c") %></td>
            <td align="right">
            <%: (line.Quantity*line.Product.Price).ToString("c") %>
            </td>
            <td>
            <% using(Html.BeginForm("RemoveFromCart", "Cart")) { %>
            <%: Html.Hidden("ProductId", line.Product.ProductID) %>
            <%: Html.HiddenFor(x => x.ReturnUrl) %>
            <input type="submit" value="Slet Vare" />
            <% } %>
            </td>
        </tr>
    <% } %>
    </tbody>
    <tfoot>
    <tr>
            <td colspan="3" align="right">Netto:</td>
            <td align="right">
            <%: (Model.Cart.ComputeTotalValue()*0.80m).ToString("c")%>
            </td>
    </tr>
    <tr>
            <td colspan="3" align="right">Moms 25%:</td>
            <td align="right">
            <%: (Model.Cart.ComputeTotalValue()*0.20m).ToString("c") %>
            </td>
    </tr>
    <tr>
            <td colspan="3" align="right">Total:</td>
            <td align="right">
            <%: Model.Cart.ComputeTotalValue().ToString("c") %>
            </td>
    </tr></tfoot>
</table>

Open in new window


and the other file
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Store.Domain.Entities
{
    public class Cart
    {
        private List<CartLine> lines = new List<CartLine>();
        public IList<CartLine> Lines { get { return lines.AsReadOnly(); } }

        public void AddItem(Product product, int quantity)
        {
            var line = lines
                .FirstOrDefault(x => x.Product.ProductID == product.ProductID);
                if (line == null)
                    lines.Add(new CartLine { Product = product, Quantity = quantity });
                else
                    line.Quantity += quantity;
        }

        public decimal ComputeTotalValue()
        { 
            return lines.Sum(l => l.Product.Price * l.Quantity); 
        }

        public void Clear()
        { 
            lines.Clear(); 
        }

        public void RemoveLine(Product product)
        {
            lines.RemoveAll(l => l.Product.ProductID == product.ProductID);
        }

        public int i { get; set; }
    }

    public class CartLine
    {
        public Product Product { get; set; }
        public int Quantity { get; set; }
    }
}

Open in new window

0
 

Accepted Solution

by:
tjgrindsted earned 0 total points
ID: 34181130
0
 

Author Closing Comment

by:tjgrindsted
ID: 34211388
i found the link myself
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question