?
Solved

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

Posted on 2010-11-20
5
Medium Priority
?
3,136 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
  • 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

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

Question has a verified solution.

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

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
The Relationships Diagram is a good way to get an overall view of what a database is keeping track of. It is also where relationships are defined. A relationship specifies how two tables connect to each other. As you build tables in Microsoft Ac…
There may be issues when you are trying to access Outlook or send & receive emails or due to Outlook crash which leads to corrupt or damaged PST file. To eliminate the corruption from your PST file, you need to repair the corrupt Outlook PST file. U…

589 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