Solved

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

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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Problem to refer to value 8 49
vb.net 1 month apart 11 30
transaction in asp.net, sql server 6 33
Linq asp.net mvc 13 10
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

810 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