Solved

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

Posted on 2010-11-20
5
2,746 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 35

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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

707 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now